Test CClass Sample

From STRIDE Wiki
Jump to navigation Jump to search

Introduction

The Test CClass test unit provides a test unit based on a C struct that is acting like a class object for the purpose of test unit containment. The Test CClass functionality is most useful for target environments that do not support C++. However, the Test CClass functionality may be used in C++ environments as well. (If you are using C++, please see Test Class Samples.)

Tests Description

Basic

These examples cover the simplest, easiest way to code a STRIDE test CClass. These examples use simple POD return types to indicate status and do not annotate the tests with any rich information (such as comments).

basic_simple

This example demonstrates passing and failing tests using the four primary POD types that infer status from (int, short, and char).

basic_fixtures

This example demonstrates how to use setup and teardown fixtures. The setup and teardown methods are called immediately before and after the execution of each test method, respectively.

Runtime Services

These examples cover basic usage of our Runtime Test Services API (as declared in srtest.h).

runtimeservices_simple

This example demonstrates how to use srTestCaseSetStatus to set status, srTestCaseAddComment to add a comment, and srTEST_ADD_COMMENT_WITH_LOCATION to add a comment that automatically includes line and file information.

runtimeservices_dynamic

This example demonstrates how to use srTestSuiteAddSuite, srTestSuiteAddCase, srTestSuiteAddAnnotation, and srTestAnnotationAddComment for dynamic suite, test case, and annotation creation in the context of a single test method.

runtimeservices_override

This example demonstrates how to use srTestCaseSetStatus to override the status that would otherwise be inferred from the return value.

runtimeservices_varcomment

This example demonstrates the use of printf style format strings with srTestCaseAddComment.