RunTest Examples
Here are some examples of using RunTest to execute your unit tests.
In order to use RunTest, you must first assign ^UnitTestRoot a valid directory name:
USER>Set ^UnitTestRoot = "C:\UnitTests"
Example 1:
USER>Do ##class(%UnitTest.Manager).RunTest()
-
Searches through all subdirectories of the ^UnitTestRoot directory for test class files. Loads any test classes that it finds and executes the tests.
-
Deletes from InterSystems IRIS all loaded test classes after they execute.
Example 2:
USER>Do ##class(%UnitTest.Manager).RunTest("mytests")
Example 3:
USER>Do ##class(%UnitTest.Manager).RunTest("mytests,-mytests\old")
-
Loads and executes tests from the mytests subdirectory (along with its subdirectories) of ^UnitTestRoot, except for mytests\old.
-
Deletes the test classes from InterSystems IRIS after they execute.
Example 4:
USER>Do ##class(%UnitTest.Manager).RunTest("mytests:MyPackage.Tests")
-
Loads tests from from the mytests subdirectory (along with its subdirectories) of the ^UnitTestRoot directory. Executes only the tests in MyPackage.Tests.
-
Deletes all test classes from InterSystems IRIS after the tests execute.
Example 5:
USER>Do ##class(%UnitTest.Manager).RunTest("mytests:MyPackage.Tests", "/noload/nodelete", "/log")
-
Loads no tests into InterSystems IRIS.
-
Executes the tests in MyPackage.Tests. Note that mytests must still contain a file with the MyPackage.Tests class.
-
Does not delete MyPackage.Tests from InterSystems IRIS.
-
Writes the test results to a file called UNITTEST.LOG in the <install-dir>/mgr directory.