IRISLIB database
TestCacheScript Class Reference

Extends TestScript. More...

Inheritance diagram for TestCacheScript:
Collaboration diagram for TestCacheScript:

Static Public Member Functions

 runScript (_.Library.String scriptfile, _.Library.String outputfile)
 Extends TestScript. More...
 

Additional Inherited Members

- Public Member Functions inherited from TestScript
 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...
 
- 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...
 
- Static Public Attributes inherited from TestScript
 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...
 

Detailed Description

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

Member Function Documentation

◆ runScript()

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

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

Reimplemented from TestScript.