Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Give example for having tests in production code #252
I recently saw https://blog.jetbrains.com/rscpp/better-ways-testing-with-doctest/ where it was stated
I would really like to try that. My expectation would be the following:
Maybe my expectation is wrong, but in any case I would like to understand how the above quote is realizable in actual code.
Your assumptions are correct - it would be as easy as just including the header and writing test cases!
To get the fastest possible compile times of asserts checkout this part of the FAQ.
As for the CMake part - yes, you'll get a single binary with all the unit tests in it, but it will be up to you to call
If your program has plugins (shared objects) which are loaded at runtime and they contain tests make sure to call the
You could even use doctest for asserts within the actual production code - even when being executed outside of a testing context!
You could write your tests at the bottom of the
Let me know if you have any further questions!