I'm starting implementing some tests using gtest. I have some methods, which request data from external, what takes some time. So I would like to do it in parallel using threads. For testing I made some simple example:
void TestThread(void) {
ASSERT_EQ(1,2);
boost::this_thread::sleep_for(boost::chrono::seconds(5));
ASSERT_EQ(2,3);
}
TEST(MySuite, MyTest) {
boost::thread myThread(TestThread);
ASSERT_EQ(0,0);
myThread.join();
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
I would expect all asserts from TestThread, but the second one is never part of test result. Also the test runs less than a second. I guess, the 'boost::thread::join' does not work, but why?
Regards, Christian
gtest-parallel is a script that executes Google Test binaries in parallel, providing good speedup for single-threaded tests (on multi-core machines) and tests that do not run at 100% CPU (on single- or multi-core machines).
gMock is bundled with googletest.
ASSERT_xxx() will abort the test if the assertion fails. EXPECT_xxx will not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With