Skip to content

Dedicated main for tests but with tests also written in production code #791

Closed Answered by viniciusferrao
viniciusferrao asked this question in Q&A
Discussion options

You must be logged in to vote

I was able to solve the issue recompiling every object two times. Yes I know that will increase the compilation time but it's a price that I'm willing to pay.

With that I just added the following to my .cpp files:

#ifdef BUILD_TESTING
#include <doctest/doctest.h>
#else
#define DOCTEST_CONFIG_DISABLE
#include <doctest/doctest.h>
#endif

So if BUILD_TESTING is enabled during compile time it will not enable DOCTEST_CONFIG_DISABLE.

Doing that I was able to achieve what I want, that was still keep the tests on the source files while maintaining a totally separate main.cpp file and support for additional separate test files.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by viniciusferrao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant