Class Reference
%UnitTest.TestCacheScript
Server:basexml
Instance:SOAXML
User:UnknownUser
 
-
  [BASEXML] >  [%UnitTest] >  [TestCacheScript]
Private  Storage

class %UnitTest.TestCacheScript extends %UnitTest.TestScript

Extends TestScript. Adds methods to test ObjectScript code.

This class compares a file called output.log to a file called reference.log.

  1. Create a new class that extends TestCacheScript called, for example, TestCacheScriptX and export it to your test directory.

  2. Create a file called script.txt in your test directory, containing ObjectScript code you want to test. Here's an example:
    w "abc"
    w $p("abc,xyz",",",Z)
    
  3. Run the test.

    d ##class(%UnitTest.Manager).RunTest("dirname",,"reference")

    Each line of code in script.txt is executed and command output is written to reference.log until the end of file in script.txt is reached. The first time that you run the test, set the third argument as "reference" (lowercase and in double quotes) to create a reference.log file. (Use "screen" as the third argument to display output on the screen.) Check that the contents of new reference.log file are correct.

  4. Run the test again

    d ##class(%UnitTest.Manager).RunTest("dirname")

Every time you run your test the new output is written to output.log. output.log is compared to reference.log. If the files match, the test passes. If the files do not match, the test fails. If the output changes, you need to update the reference.log file. Note that, in Intersystems, the default test directory is U:/internal/testing/unit_tests

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
1


Summary

Properties
Debug SkipTest

Methods
%%OIDGet %AddToSaveSet %ClassIsLatestVersion %ClassName
%ConstructClone %DispatchClassMethod %DispatchGetModified %DispatchGetProperty
%DispatchMethod %DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty
%Extends %GetParameter %IsA %IsModified
%New %NormalizeObject %ObjectModified %OnNew
%OriginalNamespace %PackageName %RemoveFromSaveSet %SerializeObject
%SetModified %ValidateObject AssertEqualsViaMacro AssertFilesSameViaMacro
AssertNotEqualsViaMacro AssertNotTrueViaMacro AssertSkippedViaMacro AssertStatusEqualsViaMacro
AssertStatusNotOKViaMacro AssertStatusOKViaMacro AssertTrueViaMacro LogMessage
OnAfterAllTests OnAfterOneTest OnBeforeAllTests OnBeforeOneTest
TestRunScript runScript


Methods

• classmethod runScript(scriptfile As %String, outputfile As %String)