Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google test functions setup() and teardown() is called for each test case or for the whole testsuit

Tags:

c++

googletest

I am using google test and trying to write test fixtures to test source code, in the test fixture, there are several test cases defined.

There are SetUp() and TearDown() functions, for those functions, if there are defined, will they be called for each test case or only once for the whole test suit?

like image 245
ratzip Avatar asked Oct 14 '25 18:10

ratzip


1 Answers

Googletest does not reuse the same test fixture object across multiple tests. For each TEST_F, googletest will create a fresh test fixture object, immediately call SetUp(), run the test body, call TearDown(), and then delete the test fixture object. Source

like image 191
Shogun Avatar answered Oct 17 '25 10:10

Shogun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!