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 Caché 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 Caché 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 Caché after the tests execute.

Example 4:


USER>Do ##class(%UnitTest.Manager).RunTest("mytests:MyPackage.Tests", "/noload/nodelete")

  • Loads no tests into Caché.

  • 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 Caché.

Note:

The test classes in the subdirectories of ^UnitTestRoot must be contained in the XML files that result from exporting the test classes, possibly along with other classes, from Caché.

FeedbackOpens in a new tab