Scl test setup
Jump to navigation
Jump to search
The scl_test_setup pragma
The scl_test_setup pragma declares a member method to be a setup fixture for the class. If specified, the setup method will be called before to the execution of each test method.
Syntax
#pragma scl_test_setup(test-unit-name, function-name)
| Parameters | Type | Description |
| test-unit-name | String | Name of a captured test unit. |
| function-name | String | Name of a member function of the test unit to be used as a setup fixture. If specified, the setup method will be called before the execution of each test method. |
Notes
- This pragma can only work in STRIDE version 2.1 or later.
- The host PC must also have a recent distribution of ActiveState Perl installed.
- Refer to the Test_Units page for more information on capturing and qualifying test classes.
Example
/*
* Example test class using Runtime test services
*
* @description
* this is a basic test class that uses the C runtime API to set status
* and add comments.
*
*/
#include <srtest.h>
class RuntimeServices_fixtures {
public:
void setup (void)
{
srTestCaseAddComment(srTEST_CASE_DEFAULT, "setup called");
}
void teardown (void)
{
srTestCaseAddComment(srTEST_CASE_DEFAULT, "teardown called");
}
void tc_ExpectPass(void)
{
srTestCaseAddComment(srTEST_CASE_DEFAULT, "this test should pass");
srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_PASS, 0);
}
void tc_ExpectFail(void)
{
srTestCaseAddComment(srTEST_CASE_DEFAULT, "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