Hello there,
I'm trying to setup a unit testing infrastructure for my company's codebase and have chosen GTest for this purpose.
I'm not able to get proper understanding of how the death tests are run. From the documentation I could find that Death tests are run in a new process.
I've the following code just to test how various death test macros work.
TEST(DataObfuscatorDeathTest, ObfuscatorAllNullParamDeathTest)
{
EXPECT_EXIT(exit(-1), ::testing::ExitedWithCode(0), "");
}
I'm running this on windows 7 with Visual studio 2013. My test project is a MFC project. Below are my questions.
1: How many processes are created when a death test is run ? In my case I see around 30 processes being created with following output.
[==========] Running 2 tests from 1 test case.
1> [----------] Global test environment set-up.
1> [----------] 2 tests from DataObfuscatorDeathTest
1> [ RUN ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1> [==========] Running 2 tests from 1 test case.
1> [----------] Global test environment set-up.
1> [----------] 2 tests from DataObfuscatorDeathTest
1> [ RUN ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1> [==========] Running 2 tests from 1 test case.
1> [----------] Global test environment set-up.
1> [----------] 2 tests from DataObfuscatorDeathTest
1> [ RUN ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1> [==========] Running 2 tests from 1 test case.
1> [----------] Global test environment set-up.
1> [----------] 2 tests from DataObfuscatorDeathTest
1> [ RUN ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1> [==========] Running 2 tests from 1 test case.
....
.....
......
[==========] Running 1 test from 1 test case.
1> [----------] Global test environment set-up.
1> [----------] 1 test from DataObfuscatorDeathTest
1> [ RUN ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1>d:\workspace\anujain_kti_rpo_elise9850_mui_str\daytona\tests\obfuscatorutilitytest\DataObfuscatorTest.h(101): error : Death test: exit(-1)
1> Result: died but not with expected exit code:
1> Exited with exit status 3
1> Actual msg:
1> [ DEATH ]
1> [ FAILED ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest (106 ms)
1> [----------] 1 test from DataObfuscatorDeathTest (106 ms total)
1>
1> [----------] Global test environment tear-down
1> [==========] 1 test from 1 test case ran. (106 ms total)
1> [ PASSED ] 0 tests.
1> [ FAILED ] 1 test, listed below:
1> [ FAILED ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest
1>
1> 1 FAILED TEST
1> YOU HAVE 9 DISABLED TESTS
1>
1> [ OK ] DataObfuscatorDeathTest.ObfuscatorAllNullParamDeathTest (209 ms)
1> [----------] 1 test from DataObfuscatorDeathTest (209 ms total)
1>
1> [----------] Global test environment tear-down
1> [==========] 1 test from 1 test case ran. (210 ms total)
1> [ PASSED ] 1 test.
1>
1> YOU HAVE 9 DISABLED TESTS
2: Why the test previously being reported as fail at last is being reported as pass.
3: Is there a way to limit the number of processes death test creates?
Kindly provide your inputs and help me understand the working of Gtest.
Thanks and regards,
Anurag Jain