-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give example for having tests in production code #252
Comments
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! |
I'll be closing this soon if there are no further questions |
I created a gist with full example mixing production code with tests using static libraries (cmake object libraries actually). This way, you only compile the production code one time and have two main applications, the test runner and the default application which just works normally: https://gist.github.com/evandrocoan/2f53228503973b205a401c76dc9fcb13 |
Description
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:
.hpp
) and implemented in source files (.cpp
).Maybe my expectation is wrong, but in any case I would like to understand how the above quote is realizable in actual code.
The text was updated successfully, but these errors were encountered: