Presentation is loading. Please wait.

Presentation is loading. Please wait.

Google C++ Testing Framework Value-Parameterized Tests.

Similar presentations

Presentation on theme: "Google C++ Testing Framework Value-Parameterized Tests."— Presentation transcript:

1 Google C++ Testing Framework Value-Parameterized Tests

2 Review isPrimeTest

3 Find Problems? Duplication Developers are lazy!

4 Revised version

5 Result screenshot

6 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.

7 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.

8 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.

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

Download ppt "Google C++ Testing Framework Value-Parameterized Tests."

Similar presentations

Ads by Google