Scl test class

From STRIDE Wiki
Revision as of 12:11, 7 October 2008 by Ivailop (talk | contribs) (The scl_test_class pragma)
Jump to: navigation, search

The scl_test_class pragma

The scl_test_class pragma is one of the Test Unit pragmas. It declares a test class as captured. Once captured, STRIDE will generate the appropriate code for executing the test methods in the class.

Syntax

#pragma scl_test_class(class-name)
Parameters Type Description
class-name String The name of the test class to be captured. Once captured, STRIDE will generate the appropriate code for executing the test methods in the class.

Notes

  • This pragma requires the compilation language to be C++. If the compilation language is not C++ and this pragma is encountered, then an error is issued and this pragma is ignored.
  • The test class identified must:
    • Have a public constructor.
    • The constructor may have parameters, but they must all be POD type.
    • Have one or more member functions that suitable as a test method. For a member function to be a test method it must:
      • be declared within the test class (method not declared, but inherited from a base class cannot be test methods)
      • have a return type of bool, an integral type (signed or unsigned long, int, short, char) or void.
      • have an empty parameter list. That is, declared as f() or f(void).
      • not be a templatized function
      • not be an overloaded operator
      • The class cannot be a pure virtual class
      • not be a static member.
    • Cannot be a templated class.
    • Cannot be a nested class.
  • 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.

Examples

#include <srtest.h>

class RuntimeServices_dynamic {
public:
  void dynamic(void);
     
  // Declaring a constructor for an scl_test_class is optional, but
  // if a constructor is declared all parameters must be of plain old data (POD) type.
  // An scl_test_class-specified class may only have one explicit public constructor.
  // Declaration of this constructor results in IM synthesization of a function
  // that initializes the test unit. The constructor parameters become parameters of 
  // the synthesized test unit.
  RuntimeServices_dynamic(int i, int j, int k);
};
    
#ifdef _SCL
#pragma scl_test_class(RuntimeServices_dynamic)
#endif

See Also

  • Refer to the Test Class Sample page for more information on capturing and qualifying test classes.