Google test - before class

Inherit from class ::testing::Environment and override methods SetUp and TearDown, these methods will contain code for your global setup and tear down. Then, in the main function of executable that runs you tests, call function ::testing::AddGlobalTestEnvironment() before calling RUN_ALL_TESTS(). For more information, check the documentation:

https://github.com/google/googletest/blob/master/docs/advanced.md#global-set-up-and-tear-down


You can define static member functions void SetUpTestCase() and void TearDownTestCase() in each of your fixture classes, i.e. in each class derived from ::testing::Test.

That code will run only once for each fixture, before and after all test in the fixture are run.

Check the docs.