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"
Copy code to clipboard

Example 1:


USER>Do ##class(%UnitTest.Manager).RunTest()
Copy code to clipboard
  • 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")
Copy code to clipboard
  • 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")
Copy code to clipboard
  • 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")
Copy code to clipboard
FeedbackOpens in a new window