Example: Executing a Test Using Setup 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.Manager:
USER> Do ##class(%UnitTest.Manager).RunTest("mytests")
-
InterSystems IRIS loads the test class, compiles the class, executes the test, and delivers a report to the terminal.
=============================================================================== Directory: C:\unittests\mytests\cls\MyPackage\ =============================================================================== mytests\cls\MyPackage begins ... Load of directory started on 01/09/2018 14:36:57 '*.xml;*.XML;*.cls;*.mac;*.int;*.inc;*.CLS;*.MAC;*.INT;*.INC' Loading file C:\unittests\mytests\cls\MyPackage\Tests.xml as xml Imported class: MyPackage.Tests Compilation started on 01/09/2018 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: .000073 sec. TestAdd passed TestEditContact() begins ... AssertStatusNotOK:ContactType = Friend (passed) AssertStatusOK:ContactType = Personal (passed) LogMessage:Duration of execution: .001227 sec. TestEditContact passed MyPackage.Tests passed mytests\cls\MyPackage passed Use the following URL to view the result: http://10.0.75.1:52773/csp/sys/%25UnitTest.Portal.Indices.cls?Index=10&$NAMESPACE=USER All PASSED