Home Corporate Contacts TETware Java API Overview |
ProductsSolutionsInformationDatasheetDocumentationFAQKnowledgebase |
5. Test Case Structure and ManagementIntroductionThese methods are used when test cases are initialised and cleaned up, and in selecting invocable components and test purposes to execute. Defining a Test Case ClassThe test case author defines a new test case by extending the SimpleTestCase class or one of its subclasses. The new test case must provide a static main() method which creates an instance of the test case class and passes control back to the Test Case Manager (TCM). For example:
The first argument to main() is the name of the test case. This name is returned by a call to the tet_pname() API method. An alternative main() method is also provided in SimpleTestCase which omits the first argument, and uses the class of the new test case object to determine the test case name. For example:
The API services are provided by the TestSession class. A TestSession object is created when the test case is initialised and this object is passed to each test purpose method in the test case. Defining Invocable Components and Test PurposesThe test suite author should define each test purpose function as a public instance method of the form:
where icnum is the invocable component (IC) number to which the test purpose belongs, and tpnum is the test purpose (TP) number within that invocable component. For example, a method that is defined as:
is interpreted by the TCM as TP 2 within IC 1. When the TCM processes a particular IC, it first selects the TP methods whose name contains an icnum which matches the number of the IC being processed. Then the TCM uses lexical comparison of the tpnum fields in the selected method names to determine the order in which to call the TP methods. A consequence of this is that it would be possible to define methods named i1t2() and i1t02(), and have the TCM interpret these as different TPs within IC 1. However, this should be regarded as bad practice since it would be difficult to associate a test purpose method name in a source file with the test purpose's information lines and result code in the journal file. Instead, test case authors should define test purpose method names whose icnum and tpnum fields either contain no leading zeros or all contain the same number of digit positions. In other words, you should either name test purpose methods using the style: i1t1(), i1t2(), i2t1() . . ., or name them using the style: i1t01(), i1t02(), i2t01() . . ., but do not mix these styles in the same test case. The SimpleTestCase class determines valid test purpose methods using the Java Reflection API. Any methods which do not have the correct name or signature will be silently ignored by the TCM. If a test purpose method throws an exception, the API registers a result of UNRESOLVED for the test purpose. startup() and cleanup()Synopsis
Description The startup() and/or cleanup() methods of SimpleTestCase may be overridden in the user-supplied test case class. These methods are called by the TCM to perform test case specific start up and clean up operations, respectively. startup() is called before the first requested invocable component and cleanup() is invoked on completion of the last requested invocable component. If a test case does not need to perform actions of start up and/or clean up, these methods need not be defined in the new test case class. tet_thistest() and tet_pname()Synopsis
Description These methods are defined on the TestSession object passed to the startup(), cleanup() and test purpose methods. The value returned by tet_thistest() is the absolute test number for the currently executing test purpose. (For a description of the relationship between invocable component number, test purpose number and absolute test number, see ``Dynamic test case interface'' in the chapter entitled ``The C API''). During execution of the startup() and cleanup() functions, tet_thistest() returns zero. tet_pname() returns the test case name. Return value These methods return the values described above. |