In this section:

Introduction

You can annotate code coverage results with test start/stop information to understand how a particular test scenario affects code execution. Test start notification conveys information about the test name, which can be used when processing test data and generating reports.

Test Start/Stop annotations functionality is available as an API and can be extended to many different scenarios. For example, you can associate code coverage results with unit tests or associate code coverage results with manual test scenarios performed during system testing.

Using the Test Start/Stop API

The API includes the following functions:

Include a dedicated header file in the source file that will invoke the API functions: 

#include "cpptest/cpptest.h"

Use the -I option to specify the cpptest.h header file location when compiling the source file: 

-I <Installation Directory>/runtime/include

Specify a valid string as an argument to the CppTest_TestStart function. Null pointers or invalid strings will cause undefined behavior.

Common Applications of the Test Start/Stop Scenarios

The following scenarios illustrate the usage of the test start/stop notification API.

Annotating coverage results with unit test case names

In this scenario, unit test case names are used as an argument specified to CppTest_TestStart function invocation. For some of popular C/C++ unit testing frameworks, dedicated connectors are provided to automate this task. For additional information about unit testing framework connectors, see Unit Testing.
To use a unit testing framework that does not have a dedicated connector, you can invoke start/stop API functions at the beginning and end of the test case:

#include "cpptest/cpptest.h"

TEST(TimerTest, smokeTest) {
  const char * tcName = testCaseName();
  CppTest_TestStart(tcName);
  int res = init_timer();
  ASSERT_TRUE(res != 0);
  CppTest_TestStop();
}

Annotating coverage results with manual test scenario names for system testing sessions

There are a few ways to achieve this goal: