1. There are several macros used in Symbian Unit Test Framework, we should define the macro SYMBIAN_UNIT_TEST in our test project’s mmp file to enable them.
BASE_CONSTRUCT:
Calls the base class constructor that sets the name of unit test, usually used in ConstructL in wrapper class.
ADD_SUT( aTestPtr ):
Adds a new unit test case to this unit test. The default setup and teardown functions will be used.
ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr ):
Adds a new unit test case to this unit test. The user can specify the customized setup and teardown functions.
SUT_ASSERT( aCondition ):
Asserts a condition in a unit test case. Leaves with a Symbian unit test framework specific error code if the condition evaluates to EFalse.
SUT_ASSERT_EQUALS( aExpected, aActual ):
Asserts that two values are equal. Leaves with a Symbian unit test framework specific error code if the values are not equal.
SUT_ASSERT_LEAVE_WITH( aStatement, aError ):
Asserts that a statement leaves an expected value. Leaves with a Symbian unit test framework specific error code if the leave code is not the expected one.
SUT_ASSERT_LEAVE( aStatement ):
Asserts that a statement leaves. The macro itself leaves with a Symbian unit test framework specific error code if the statement leaves.
The detailed explaination can be found in symbianunittestmacros.h.
2. Classes in Symbian Unit Test Framework.
In this section, we will review some key classes in SymbianUnitTest Framework. While writing a test project, below classes should be aware of from the client’s perspective:
CSymbianUnitTest
CSymbianUnitTest is a basic test unit; it corresponds to the class which we will test. Client programmer should derive from it and implement test code in CSymbianUnitTest’s derived class.
Client user needs to override two methods SetupL and Teardown if extra initialization needed to run test case.
CSymbianUnitTestSuite
CSymbianUnitTestSuite is the collection/container of CSymbianUnitTest. On the other words, it simply collects a number of CSymbianUnitTest's derived classes and run them during a particular test run.