Main Content

Test Authoring Using C/C++ xUnit API

R2026b
Write tests using C or C++ macros, group tests into suites, parametrize tests

Author tests for C/C++ code by using the Polyspace® Test™ xUnit API. Group tests into suites, use assertion macros to verify expected behavior, and add setup and teardown functions for common initialization.

A test declares a suite and uses assertion macros to check results:

PST_SUITE(arith_operations);

PST_TEST(arith_operations, test_times_two) {
    int result = times_two(3);
    PST_ASSERT_EQ_INT(result, 6);
}

Build your tests and sources along with the Polyspace Test header files by using your existing toolchain, or add them to a Polyspace Platform project.

System Commands

polyspace-test -generate(System Command) Generate test registration function from a set of Polyspace Test C/C++ test files

Topics

Getting Started

Creating Tests

Writing Assessments

Grouping Tests

Parametrizing Tests

Range Specification

Adding to Polyspace Platform Projects

Release-Specific Changes