Google C++ Testing Framework


Google C++ Testing Framework Value-Parameterized Tests

Review isPrimeTest

Find Problems?   Duplication Developers are lazy!

Revised version

Result screenshot

Write value-parameterzied tests  Step 1: Define a fixture class. ◦ Be derived from ::testing::TestWithParam, where T is the type of your parameter values.

◦ TestWithParam is itself derived from ::testing::Test.

 T can be any copyable type.  If it's a raw pointer, you are responsible for managing the lifespan of the pointed values.

 Step 2: use the TEST_P macro ◦ To define as many test patterns using this fixture as you want. ◦ The _P suffix is for "parameterized" or "pattern", whichever you prefer to think.

 Step 3: use INSTANTIATE_TEST_CASE_P ◦ to instantiate the test case with any set of parameters you want. ◦ Google Test defines a number of functions for generating test parameters.  They return what we call (surprise!) parameter generators.

Functions for generating test parameters  all in the testing namespace: