Scl test teardown: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 33: | Line 33: | ||
void setup (void) | void setup (void) | ||
{ | { | ||
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "setup called"); | |||
} | } | ||
void teardown (void) | void teardown (void) | ||
{ | { | ||
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "teardown called"); | |||
} | } | ||
void tc_ExpectPass(void) | void tc_ExpectPass(void) | ||
{ | { | ||
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "this test should pass"); | |||
srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_PASS, 0); | srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_PASS, 0); | ||
} | } | ||
void tc_ExpectFail(void) | void tc_ExpectFail(void) | ||
{ | { | ||
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_ERROR, srNULL, "this test should fail"); | |||
srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_FAIL, 0); | srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_FAIL, 0); | ||
} | } |
Latest revision as of 19:25, 5 August 2014
The scl_test_teardown pragma
The scl_test_teardown pragma declares a member method to be a teardown fixture for an existing test unit. The teardown method will be called after the execution of each test method.
Syntax
#pragma scl_test_teardown(test-unit-name, function-name)
Parameters | Type | Description |
test-unit-name | Identifier | Name of a captured test unit. |
function-name | Identifier | Name of a member function of the test unit to be used as a teardown fixture. |
Notes
- This pragma identifies the setup fixture of an existing test unit, i.e. either a class with scl_test_class applied to it, a set of functions with scl_test_flist applied to it, or a C struct with scl_test_cclass applied to it.
- There may be only one teardown fixture per test unit.
Example
#include <srtest.h>
class RuntimeServices_fixtures {
public:
void setup (void)
{
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "setup called");
}
void teardown (void)
{
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "teardown called");
}
void tc_ExpectPass(void)
{
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_INFO, srNULL, "this test should pass");
srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_PASS, 0);
}
void tc_ExpectFail(void)
{
srTestCaseAddAnnotation(srTEST_CASE_DEFAULT, srTEST_ANNOTATION_LEVEL_ERROR, srNULL, "this test should fail");
srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_FAIL, 0);
}
};
#ifdef _SCL
#pragma scl_test_class(RuntimeServices_fixtures)
#pragma scl_test_setup(RuntimeServices_fixtures, setup)
#pragma scl_test_teardown(RuntimeServices_fixtures, teardown)
#endif
See Also
- Refer to the Test Units page for more information on capturing and qualifying test units.