You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanna to do tests of two functions with one setup. According to instructions I made TEST_CASE with SUBCASEs (also tried with SCENARIO and WHEN-THEN-THEN), but this makes my setup being runned with every subcase. I don't know what do I do wrong.
main
#defineDOCTEST_CONFIG_IMPLEMENT
#include<doctest.h>//my includes...//#define DOCTEST_CONFIG_DISABLEintmain(int argc, char* argv[])
{
int result = 0;
#ifdef DOCTEST_CONFIG_DISABLE
result = MyProgram(argc, argv);
#else
doctest::Context testContext(argc, argv);
result = testContext.run();
if(testContext.shouldExit())
return result;
#endifreturn result;
}
Hi! Actually the setup should indeed be ran multiple times in this case - see the relevant docs - and also here is the slide from my doctest presentation - the setup is indeed being ran multiple times because the test case is re-entered multiple times (depending on the number of leaf subcase nodes there are - think of it as a nested tree of subcases and a DFS-ish traversal).
So if you want the setup to be ran just once and have 2 functions checked after it - just do this:
Thank You for reply,
I saw that links; watching this slide again... I was wrong, eh. :-) Don't know why I was convinced to have one setup in this configuration.
I was wondering to have msg to every check, that's why I wanted to use case for every check. But after a while of reflection I found that few check in one case are sufficient - There is enough info.
I wanna to do tests of two functions with one setup. According to instructions I made TEST_CASE with SUBCASEs (also tried with SCENARIO and WHEN-THEN-THEN), but this makes my setup being runned with every subcase. I don't know what do I do wrong.
main
*.cpp with tested functions
According to found slides it should run setup only once, but it runs before sunc1 and second time before func2
The text was updated successfully, but these errors were encountered: