background:I am writing a Session table for incoming traffic. This table should hold all active UDP/TCP connections.
I am using googletest package to test my implementation. I prepare a parameterised test based on fixture in the following format:
class SessionTest - initialize all staff.
struct ConnectionInfo - holds set of connection parameters (IPs, ports, etc..)
class SessionTestPrepare : SessionTest , testing::WithParamInterface<ConnectionInfo> - initialization.
TEST_P(SessionTestPrepare, test) - holds the test cases and logic.
INSTANTIATE_TEST_CASE_P(default, SessionTestPrepare_ testing::Values(
ConectionInfo{},
ConectionInfo{},
ConectionInfo{},
)
I noticed that each time new parameters are tested, the SessionTest constructor and Setup function are called (and of course destructor and TearDown).
Note: my sessionTable is declared and initialized here.
- Is there a way to avoid calling to SetUp and TearDown after each set of parameter test?
- Is there a way to keep the state of my Session Table after each test without make it global (i.e. when testing the second connection parameters, the first is still in table)?