Google test - before class

Rat picture Rat · Mar 7, 2016 · Viewed 11k times · Source

I'm running google test.

I need something like Before class. I have the SetUp() and TearDown() functions, but they run before and after each test. Now I need something global - like ctor, that should run only one time when the class loaded.

Answer

Antonio Pérez picture Antonio Pérez · Mar 7, 2016

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.