Example: Executing a Test Using Set-Up and Tear Down Methods
Execute the new unit test in the usual fashion.
-
Open the Terminal in the namespace in which you have been working.
-
Set the value of ^UnitTestRoot to the parent of the directory containing your test class:
USER> Set ^UnitTestRoot="c:\unittests"
-
Execute the tests using %UnitTest.ManagerOpens in a new tab:
USER> Do ##class(%UnitTest.Manager).RunTest("mytests")
-
Caché loads the test class from the XML file, compiles the class, executes the test, and delivers a report to the terminal.
=============================================================================== Directory: C:\unittests\mytests\ =============================================================================== mytests begins ... Load of directory started on 09/29/2014 15:44:01 '*.xml;*.XML' Loading file C:\unittests\mytests\Test.xml as xml Imported class: MyPackage.Tests Compilation started on 09/29/2014 15:44:01 with qualifiers '' Compiling class MyPackage.Tests Compiling routine MyPackage.Tests.1 Compilation finished successfully in 0.033s. Load finished successfully. MyPackage.Tests begins ... TestAdd() begins ... AssertEquals:Test Add(2,2)=4 (passed) AssertNotEquals:Test Add(2,2)'=5 (passed) LogMessage:Duration of execution: .002255 sec. TestAdd passed TestEditContact() begins ... AssertStatusNotOK:ContactType = Friend (passed) AssertStatusOK:ContactType = Personal (passed) LogMessage:Duration of execution: .10459 sec. TestEditContact passed MyPackage.Tests passed mytests passed