Example: Executing a Test
Now execute the unit test using %UnitTest.Manager.RunTest. Here's how:
Open the Terminal in the namespace that contains your unit tests; in this example USER. If the Terminal does not open in the correct namespace, use ZN to change namespaces.
Set the value of the ^UnitTestRoot global to the parent of the directory containing your exported test class.
USER>Set ^UnitTestRoot="c:\unittests"Copy code to clipboard
Execute the test using the method %UnitTest.Manager.RunTest.
USER>do ##class(%UnitTest.Manager).RunTest("mytests")Copy code to clipboard
InterSystems IRIS loads the test class from the XML file, compiles the class, executes the test, deletes the test code from the server, 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 14:36:57 with qualifiers '' Compiling class MyPackage.Tests Compiling routine MyPackage.Tests.1 Compilation finished successfully in 0.026s. 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: .006455 sec. TestAdd 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=8&$NAMESPACE=USER All PASSEDCopy code to clipboard
The last line shows the URL for the test report.
Running Tests in this fashion deletes them from InterSystems IRIS after they execute. If you return to Atelier to view Tests after executing the test, you will see an indication that the file visible in Atelier is not synchronized with the server. You can save or recompile the class to add the code back to the server.
If you are using .cls files rather than XML files, you must supply the /loadudl qualifier to RunTest.