Coder Social home page Coder Social logo

c4deszes / cmake-pytest-module Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 8 KB

CMake module that allows discovery and execution of Pytest tests through CTest

License: BSD 3-Clause "New" or "Revised" License

CMake 79.98% Python 20.02%
cmake pytest testing ctest

cmake-pytest-module's Introduction

CMake Pytest module

License

This module allows the discovery of Pytest scripts and exposes them through CTest.


About

The advantage of using this module is that you can use a common filtering and configuration mechanism if you use CMake with for example GoogleTest or other tools that also integrate into the CTest runner.


Usage

In your CMake include the Pytest.cmake file, you must enable tests in your project as well as have a suitable Python installation with Pytest module installed.

project(MyProject)

find_package(Python COMPONENTS Interpreter Development)
enable_testing()

include(Pytest.cmake)

pytest_discover_tests(
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    TEST_PREFIX "UNITTEST_"
    TEST_SUFFIX "_${CMAKE_SYSTEM_PROCESSOR}"
    XML_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/report
)

For more information see the module itself, it has inline documentation.

Skipped tests

During execution tests that are deselected will be marked as skipped, this should only happen if the collection arguments were different than execution arguments. Skipped tests can also be picked up by ctest but this requires setting the exit code to 5 when no tests were executed, something which is not done by pytest, see issues #812 and #5689. This can be solved with a few hooks, see example conftest.


License

License

cmake-pytest-module's People

Contributors

c4deszes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.