Class Reference
IRIS for UNIX 2024.1.2
InterSystems: The power behind what matters   
Documentation  Search
  [USER] >  [%UnitTest] >  [TestScript]
Private  Storage   

class %UnitTest.TestScript extends %UnitTest.TestCase

This class is an example of extending the TestCase class for your own testing needs. It provides the TestRunScript method, which replays the script specified in the TESTFILE parameter, comparing it to a reference log of expected output.

To use this class for your tests, write a subclass that implements the runScript method to read a script and generate repeatable output. Pass the string "reference" as the userparam parameter to the RunTest method to record the expected output to reference.log:

	d ##class(%UnitTest.Manager).RunTest("example\suite",,"reference")
In subsequent runs, call RunTest without "reference" to compare the output to reference.log:
	d ##class(%UnitTest.Manager).RunTest("example\suite")
See the TestCacheScript and TestSqlScript classes for examples.

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
2 2


Summary

Properties
AutoPassword Debug SkipTest

Methods
%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 AssertFailureViaMacro
AssertFilesSQLUnorderedSameViaMacro AssertFilesSameViaMacro AssertNotEqualsViaMacro
AssertNotTrueViaMacro AssertSkippedViaMacro AssertStatusEqualsViaMacro
AssertStatusNotOKViaMacro AssertStatusOKViaMacro AssertSuccessViaMacro
AssertTrueViaMacro Checkout LogMessage
OnAfterAllTests OnAfterOneTest OnBeforeAllTests
OnBeforeOneTest TestRunScript runScript

Subclasses
%UnitTest.TestCacheScript %UnitTest.TestSqlScript

Parameters

• parameter TESTFILE;
File that contains the test steps, in a format determined by the runScript method.
• parameter UNORDEREDFILESAME = 0;
Set to 1 to call $$$AssertFilesSQLUnorderedSame rather than $$$AssertFilesSame

Methods

• method TestRunScript()
This method, which is run automatically by %UnitTest.Manager, calls the implementation of runScript supplied by a subclass. If the TESTFILE parameter is not specified, it uses script.txt.

When the "reference" parameter is specified, it writes expected output to reference.log. Otherwise, it compares the output to reference.log using $$$AssertFilesSame (or $$$AssertFilesSQLUnorderedSame if the UNORDEREDFILESAME parameter is set).

• abstract classmethod runScript(scriptfile As %String, outputfile As %String)
Override this method with an implementation that reads from scriptfile, writing the output to outputfile. The output should be repeatable for a given script; not dependent on, e.g., the time or the system under test.


Copyright (c) 2025 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.