Creating and Executing a Suite of Unit Tests
Here are the basic steps for creating and executing a suite of unit tests:
-
Create a class (or more than one) that contains methods that you would like to test.
-
Create a test class (or more than one test class) that extends %UnitTest.TestCaseOpens in a new tab.
-
Add methods to the test class that will test your method output. Use at least one assertion (AssertX macro) in each method. Begin each test method name with Test.
-
Export the test class(es) to an XML file.
-
Open the Terminal and point it at the namespace containing the class(es) that you are going to test. Assign to ^UnitTestRoot a string containing the path to the parent of the directory that contains the exported test class XML files.
-
In the Terminal, run %UnitTest.Manager.RunTest passing it the name of the (child) directory that contains the test class XML files.
-
Review the test reports. The output in the Terminal includes a URL for a CSP page that display the results in easy-to-read tables.
The following pages provide more detail as well as step-by-step examples for creating and executing a set of unit tests.