testdev/ite/src/com.nokia.testfw.sut.help/html/references/classes_and_macros.htm
changeset 1 96906a986c3b
equal deleted inserted replaced
0:f1112f777ce9 1:96906a986c3b
       
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
       
     2 <html>
       
     3 <head>
       
     4 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
       
     5 <title>Classes and macros</title>
       
     6 <link href="../book.css" type="text/css" rel="stylesheet"></head>
       
     7 <body>
       
     8 
       
     9 <h2>Classes and macros</h2>
       
    10 
       
    11 <p>1. There are several macros used in Symbian Unit Test Framework, we should define the macro SYMBIAN_UNIT_TEST in our test project&rsquo;s mmp file to enable them.</p>
       
    12 <p>BASE_CONSTRUCT:<br />
       
    13 &nbsp;&nbsp;&nbsp; Calls the base class constructor that sets the name of unit test, usually used in ConstructL in wrapper class.</p>
       
    14 <p>ADD_SUT( aTestPtr ):<br />
       
    15 &nbsp;&nbsp;&nbsp; Adds a new unit test case to this unit test. The default setup and teardown functions will be used.</p>
       
    16 <p>ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr ):<br />
       
    17 &nbsp;&nbsp;&nbsp; Adds a new unit test case to this unit test. The user can specify the customized setup and teardown functions. <br />
       
    18 &nbsp;&nbsp;&nbsp; <br />
       
    19 SUT_ASSERT( aCondition ):<br />
       
    20 &nbsp;&nbsp;&nbsp; Asserts a condition in a unit test case. Leaves with a Symbian unit test framework specific error code if the condition evaluates to EFalse.</p>
       
    21 <p>SUT_ASSERT_EQUALS( aExpected, aActual ):<br />
       
    22 &nbsp;&nbsp;&nbsp; Asserts that two values are equal. Leaves with a Symbian unit test framework specific error code if the values are not equal.</p>
       
    23 <p>SUT_ASSERT_LEAVE_WITH( aStatement, aError ):<br />
       
    24 &nbsp;&nbsp;&nbsp; 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.</p>
       
    25 <p>SUT_ASSERT_LEAVE( aStatement ):<br />
       
    26 &nbsp;&nbsp;&nbsp; Asserts that a statement leaves. The macro itself leaves with a Symbian unit test framework specific error code if the statement leaves.</p>
       
    27 <p>The detailed explaination can be found in symbianunittestmacros.h.</p>
       
    28 <p>2. Classes in Symbian Unit Test Framework.</p>
       
    29 <p>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&rsquo;s perspective:</p>
       
    30 <p>CSymbianUnitTest<br />
       
    31 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&rsquo;s derived class. <br />
       
    32 Client user needs to override two methods SetupL and Teardown if extra initialization needed to run test case.</p>
       
    33 <p>CSymbianUnitTestSuite<br />
       
    34 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.</p>
       
    35 </body>
       
    36 </html>