Skip to main content

Example: Executing a Test Using Setup and Tear Down Methods

Execute the new unit test in the usual fashion.

  1. Open the Terminal in the namespace in which you have been working.

  2. Set the value of ^UnitTestRoot to the parent of the directory containing your test class:

    USER> Set ^UnitTestRoot="c:\unittests"
  3. Execute the tests using %UnitTest.Manager:

    USER> Do ##class(%UnitTest.Manager).RunTest("mytests")
  4. InterSystems IRIS loads the test class, compiles the class, executes the test, and delivers a report to the terminal.

    Directory: C:\unittests\mytests\cls\MyPackage\
    mytests\cls\MyPackage begins ...
    Load of directory started on 01/09/2018 14:36:57 '*.xml;*.XML;*.cls;*.mac;*.int;*.inc;*.CLS;*.MAC;*.INT;*.INC'
    Loading file C:\unittests\mytests\cls\MyPackage\Tests.xml as xml
    Imported class: MyPackage.Tests
    Compilation started on 01/09/2018 15:44:01 with qualifiers ''
    Compiling class MyPackage.Tests
    Compiling routine MyPackage.Tests.1
    Compilation finished successfully in 0.033s.
    Load finished successfully.
      MyPackage.Tests begins ...
          TestAdd() begins ...
            AssertEquals:Test Add(2,2)=4 (passed)
            AssertNotEquals:Test Add(2,2)'=5 (passed)
            LogMessage:Duration of execution: .000073 sec.
          TestAdd passed
          TestEditContact() begins ...
            AssertStatusNotOK:ContactType = Friend (passed)
            AssertStatusOK:ContactType = Personal (passed)
            LogMessage:Duration of execution: .001227 sec.
          TestEditContact passed
        MyPackage.Tests passed
      mytests\cls\MyPackage passed
    Use the following URL to view the result:$NAMESPACE=USER
    All PASSED