Skip to main content

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 XML files containing test classes. 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")
  • Loads and executes tests from the mytests subdirectory (along with its subdirectories) of ^UnitTestRoot.

  • Deletes the test classes from InterSystems IRIS after they execute.

Example 3:


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 4:


USER>Do ##class(%UnitTest.Manager).RunTest("mytests:MyPackage.Tests", "/noload/nodelete")
  • Loads no tests into InterSystems IRIS.

  • Executes the tests in MyPackage.Tests. Note that mytests must still contain an XML file with the MyPackage.Tests class.

  • Does not delete MyPackage.Tests from InterSystems IRIS.

Feedback