8000 Give example for having tests in production code · Issue #252 · doctest/doctest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Give example for having tests in production code #252
Closed
@nlohmann

Description

@nlohmann

Description

I recently saw https://blog.jetbrains.com/rscpp/better-ways-testing-with-doctest/ where it was stated

What truly sets it apart is the ability to use it alongside your production code.

I would really like to try that. My expectation would be the following:

  • I have a large project containing of dozens of classes, each define in headers (.hpp) and implemented in source files (.cpp).
  • I would add test sections to each of the implementations (maybe at the bottom).
  • For "production" mode, I would compile the code as is - maybe defining or undefining some preprocessor symbol to switch off compilation of any test code.
  • For testing, I would like to reuse as much CMake code I already have and "just" recompile such that I have a single binary executing all the test distributed along the different implementation files.

Maybe my expectation is wrong, but in any case I would like to understand how the above quote is realizable in actual code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0