IRISLIB database
TestScript Class Reference

This class is an example of extending the <class>TestCase</class> class for your own testing needs. More...

Inheritance diagram for TestScript:
Collaboration diagram for TestScript:

Public Member Functions

 TestRunScript ()
 This method, which is run automatically by <class>UnitTest.Manager</class>, calls the implementation of <method>runScript</method> supplied by a subclass. More...
 
- Public Member Functions inherited from TestCase
_.Library.Boolean AssertEqualsViaMacro (autoquoted, value1, value2, description)
 Returns true if two values are equal. More...
 
_.Library.Boolean AssertFailureViaMacro (message)
 Unconditionally log a failure. More...
 
_.Library.Boolean AssertFilesSQLUnorderedSameViaMacro (autoquoted, file1, file2, description, ignoreOrderBy, skipPlan, noheader)
 Returns true if two files containing SQL query results contain the same unordered results. More...
 
_.Library.Boolean AssertFilesSameViaMacro (autoquoted, file1, file2, description)
 Returns true if two files are identical. More...
 
_.Library.Boolean AssertNotEqualsViaMacro (autoquoted, value1, value2, description)
 Returns true if expressions are not equal. More...
 
_.Library.Boolean AssertNotTrueViaMacro (autoquoted, value, description)
 Returns true if the expression is not true. More...
 
_.Library.Boolean AssertSkippedViaMacro (message)
 An assertion to state that the test has been skipped for the reason described in the assertion's message. More...
 
_.Library.Boolean AssertStatusEqualsViaMacro (autoquoted, value1, value2, description)
 Returns true if two statuses are equal. More...
 
_.Library.Boolean AssertStatusNotOKViaMacro (autoquoted, status, description)
 Returns true if the status code is not a successful status code. More...
 
_.Library.Boolean AssertStatusOKViaMacro (autoquoted, status, description)
 Returns true if the status code is $$$OK. More...
 
_.Library.Boolean AssertSuccessViaMacro (message)
 Unconditionally log success. More...
 
_.Library.Boolean AssertTrueViaMacro (autoquoted, value, description)
 Returns true if expression is true. More...
 
 Checkout (file1, file2, forceref)
 Helper method that will check out the one file in Perforce and copy the output to the reference file. More...
 
 LogMessage (message)
 Enter a message in quotes, such as "Start of test". More...
 
_.Library.Status OnAfterAllTests ()
 Run by RunTest once after all test methods in the test class are run. More...
 
_.Library.Status OnAfterOneTest (_.Library.String testname)
 Run by RunTest immediately after each test method in the test class is run. More...
 
_.Library.Status OnBeforeAllTests ()
 Run by RunTest once before any test methods in the test class are run. More...
 
_.Library.Status OnBeforeOneTest (_.Library.String testname)
 Run by RunTest immediately before each test method in the test class is run. More...
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnClose ()
 This callback method is invoked by the <METHOD>Close</METHOD> method to. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 

Static Public Member Functions

 runScript (_.Library.String scriptfile, _.Library.String outputfile)
 Override this method with an implementation that reads from scriptfile, writing the output to outputfile. More...
 

Static Public Attributes

 TESTFILE = None
 File that contains the test steps, in a format determined by the <method>runScript</method> method.
 
 UNORDEREDFILESAME = None
 Set to 1 to call $$$AssertFilesSQLUnorderedSame rather than $$$AssertFilesSame.
 
- Static Public Attributes inherited from TestCase
 AutoGiveUsersNSAccess = None
 Extend this class to create new test case classes. More...
 
 AutoUserNames = None
 String of test users. More...
 
 AutoUserResources = None
 Optional: specifies resources for each test user in AutoUserNames. More...
 
 AutoUserRoles = None
 Optional: specifies roles for each test user in AutoUserNames. More...
 
- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 

Additional Inherited Members

- Public Attributes inherited from TestCase
 AutoPassword
 If UnitTest.Manager creates test users specified by AutoUserNames, it will generate a random-string password. More...
 
 Debug
 Use the /debug flag with UnitTest.Manager.RunTest to break into debug mode on the first failure. More...
 
 SkipTest
 The SkipTest property gets set when a test is being skipped. More...
 

Detailed Description

This class is an example of extending the <class>TestCase</class> class for your own testing needs.

It provides the <method>TestRunScript</method> method, which replays the script specified in the <parameter>TESTFILE</parameter> parameter, comparing it to a reference log of expected output.

To use this class for your tests, write a subclass that implements the <method>runScript</method> 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 <class>TestCacheScript</class> and <class>TestSqlScript</class> classes for examples.

Member Function Documentation

◆ TestRunScript()

TestRunScript ( )

This method, which is run automatically by <class>UnitTest.Manager</class>, calls the implementation of <method>runScript</method> supplied by a subclass.

If the <parameter>TESTFILE</parameter> 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 <parameter>UNORDEREDFILESAME</parameter> parameter is set).

◆ runScript()

runScript ( _.Library.String  scriptfile,
_.Library.String  outputfile 
)
static

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.

Reimplemented in TestSqlScript, and TestCacheScript.