I've started to use google test fixture and in my test suite I need to open/close a file only once , open the file before the first test start and close it after that the last test has been executed. I wonder if there is a method of the fixture that allow to do an action only ones at the beginning/end of the test suite.
Declare static
member variable to hold file object and define it outside the fixture class
.
After that, define static void SetUpTestSuite()
and use it to open your file and static void TearDownTestSuite()
to close your file.
google test will call SetUpTestSuite()
before first test and TearDownTestSuite()
after last test.
You can also check Sharing Resources Between Tests in the Same Test Suite from the official documentation