<style type="text/css"> INFO { display: block; white-space: pre; font-size: 16px; font-family: monospace; margin-left: 20px; } arg { font-style: italic; font-weight: bold; } .info-head { white-space: pre; font-family: 'Courier New'; } table.parm-format { border-collapse: collapse; border-width: 1px; margin-top: 20px; } table.parm-format TD { border: 1px solid black; padding: 0px 10px 0px 10px; } </style> More...
Public Member Functions | |
_.Library.Status | OnClose () |
This callback method is invoked by the <METHOD>Close</METHOD> method to. More... | |
_.Library.Integer | GetTestStatus (suite, case, method, action) |
Returns result for a given suite, case, method, and action. | |
_.Library.Boolean | IsSuccess (suite, case, method, action) |
This method is obsolete, use method GetTestStatus | |
_.Library.Integer | LogStateEnd (duration) |
Record the end of a test and also return the status of this. | |
_.Library.Status | OnAfterOneTest (_.Library.String suite, _.Library.String class, _.Library.String method) |
Called after a test (method starting with "Test" in a class extending <class>UnitTest.TestCase</class>) is run. More... | |
OnAfterSaveResult (userparam) | |
Called at the end of SaveResult() to perform any result aggregation tasks required by subtasks. | |
_.Library.Status | OnAfterTestCase (_.Library.String suite, _.Library.String class, _.UnitTest.TestCase testcase) |
Called after a test case (class extending <class>UnitTest.TestCase</class>) is run. More... | |
_.Library.Status | OnAfterTestSuite (_.Library.String dir, _.Library.String suite, _.Library.String testspec, qstruct) |
Called after a test suite is run. More... | |
_.Library.Status | OnBeforeAutoLoad (_.Library.String dir, _.Library.String suite, _.Library.String testspec, qstruct) |
Called before autoload, which occurs before each test suite is run. More... | |
_.Library.Status | OnBeforeOneTest (_.Library.String suite, _.Library.String class, _.Library.String method) |
Called before a test (method starting with "Test" in a class extending <class>UnitTest.TestCase</class>) is run. More... | |
_.Library.Status | OnBeforeTestCase (_.Library.String suite, _.Library.String class, _.UnitTest.TestCase testcase) |
Called before a test case (class extending <class>UnitTest.TestCase</class>) is run. More... | |
_.Library.Status | OnBeforeTestSuite (_.Library.String dir, _.Library.String suite, _.Library.String testspec, qstruct) |
Called a test suite is run. More... | |
_.Library.Status | deleteLoadedClasses (classLoaded, autoloadArray, utLoadedArray) |
def | __init__ (self) |
Deprecated, use <PROPERTY>ResultId</PROPERTY>. More... | |
![]() | |
_.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 | 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 | |
_.Library.Status | ConvertLogData (pLogIndex, pResultNamespace, pMachine, pConfiguration, pVersion, pUserParam, pKillLog) |
This method converts old format data in ^UnitTestLog to the new ^UnitTest.Result format. More... | |
_.Library.Status | ConvertStatus (pIndex, pNamespace) |
This method updates the status at each level recursively based on the status of the children. More... | |
_.Library.Status | DebugLoadTestSuite (_.Library.String testsuite, _.Library.String qspec) |
Loads, but does not run tests in the testsuite. More... | |
_.Library.Status | DebugRunTestCase (_.Library.String testsuite, _.Library.String testcase, _.Library.String qspec, _.Library.String testmethod, userparam) |
Runs a test case, but does not load. More... | |
_.Library.Status | OnAfterAllTests (_.UnitTest.Manager manager, _.Library.String dir, qstruct, userparam) |
Called after all unit tests are run. More... | |
_.Library.Status | OnBeforeAllTests (_.UnitTest.Manager manager, _.Library.String dir, qstruct, userparam) |
Called before any unit tests are run. More... | |
_.Library.String | Root () |
Returns the root directory of the unit test hierarchy, usually ^UnitTestRoot. | |
_.Library.Status | RunTest (_.Library.String testspec, _.Library.String qspec, userparam) |
Runs classes that extend UnitTest.TestCase that contain test methods. More... | |
_.Library.Status | RunTestSuites (_, _.Library.String testspec, _, qspec, _, userparam) |
Same as RunTest, but requires three arguments. More... | |
_.Library.Status | RunTestsFromFileList (_.Library.String globalName, _.Library.String fileName, qualifiers, userparam) |
Run the tests that are listed within the specified fileName. More... | |
WipeNamespace () | |
Wipe all data from this namespace and all PPG information also. More... | |
_.Library.Status | addToExcludeGlobal (_.Library.String excludeUTPath) |
_.Library.Status | getLoadedClass (classes, skipClasses) |
Public Attributes | |
CurrentDir | |
The directory that contains the current test. More... | |
Debug | |
Set to true if the /debug qualifier is on. More... | |
Display | |
Set to true if the /display=all qualifier is set. More... | |
LoadUDL | |
Set to true if the /loadudl qualifier is set. More... | |
LoadXML | |
Set to true if the /loadxml qualifier is set. More... | |
LogIndex | |
ReportVariableLeaks | |
Set to true if unexpected public variables should trigger an error. More... | |
ResultId | |
Property to hold results instance slot in ^UnitTest.Manager More... | |
UserFields | |
Allow users to store additional information, like platform, product version, etc. More... | |
UserParam | |
Set by the third argument, userparam, of the RunTest method, if specified. More... | |
Private Member Functions | |
_.Library.Status | __CleanNamespace () |
Internal method to clean the namespace after running a suite of tests. | |
_.Library.Status | __RecordNamespace () |
Internal method to log list of globals, routines in this namespace so we can cleanup after the tests. | |
Private Attributes | |
__TheStack | |
Private property for internal use only. More... | |
Additional Inherited Members | |
![]() | |
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... | |
<style type="text/css"> INFO { display: block; white-space: pre; font-size: 16px; font-family: monospace; margin-left: 20px; } arg { font-style: italic; font-weight: bold; } .info-head { white-space: pre; font-family: 'Courier New'; } table.parm-format { border-collapse: collapse; border-width: 1px; margin-top: 20px; } table.parm-format TD { border: 1px solid black; padding: 0px 10px 0px 10px; } </style>
Launches tests using any of the following methods:
RunTest: Runs a set of tests and deletes all test classes afterwards.
RunTestSuites: Same as RunTest, but requires 3 arguments, all of which can be null.
DebugRunTestCase: Can be used after DebugLoadTestSuite. It runs tests and does not delete the test classes afterwards, like RunTest does.
Setup: Set the global variable ^UnitTestRoot to a root directory that contains your test suites.
This must point to a valid directory. Example: Set ^UnitTestRoot="C:\MyUnittests" (adding a final slash is optional).
Specifically, the RunTest method does the following:
The loading, running and deletion actions each can be skipped by specifying /noload, /norun and /nodelete qualifiers.
Unit test logs testcase output to the global ^UnitTest.Result. Results displayed on CSP pages come from this global.
def __init__ | ( | self | ) |
Deprecated, use <PROPERTY>ResultId</PROPERTY>.
_.Library.Status OnClose | ( | ) |
This callback method is invoked by the <METHOD>Close</METHOD> method to.
provide notification that the current object is being closed.
The return value of this method is ignored.
Reimplemented from RegisteredObject.
|
static |
This method converts old format data in ^UnitTestLog to the new ^UnitTest.Result format.
pLogIndex is the test instance index in ^UnitTestLog.
pResultNamespace is the namespace for ^UnitTest.Result.
pMachine, pConfiguration, pVersion and pUserParam are the new information ^UnitTest.Result collects but ^UnitTestLog does not. You can provide this information manually here when doing the conversion.
pUserParam is used the same way as the userparam argument which is the 3rd argument to the RunTest method. The top node of pUserParam becomes UserParam and the first level subscripts and their values are used to populate the UserFields array.
|
static |
This method updates the status at each level recursively based on the status of the children.
If pIndex is omitted, all the TestInstances will be converted.
|
static |
Loads, but does not run tests in the testsuite.
You can use DebugLoadTestSuite to load tests and then use DebugRunTestCase to run a test over and over again, without having to reload the tests. If you are a developer, use DebugLoadTestSuite with DebugRunTestCase to load once and then run your test many times as you debug your code.
|
static |
Runs a test case, but does not load.
testsuite and testcase are required. testcase is in the form package.class. testmethod is a method within the class. See DebugLoadTestSuite for use to test code during development.
|
static |
Called after all unit tests are run.
If an error status is returned, it is logged.
_.Library.Status OnAfterOneTest | ( | _.Library.String | suite, |
_.Library.String | class, | ||
_.Library.String | method | ||
) |
Called after a test (method starting with "Test" in a class extending <class>UnitTest.TestCase</class>) is run.
If an error status is returned, it is logged.
_.Library.Status OnAfterTestCase | ( | _.Library.String | suite, |
_.Library.String | class, | ||
_.UnitTest.TestCase | testcase | ||
) |
Called after a test case (class extending <class>UnitTest.TestCase</class>) is run.
If an error status is returned, it is logged.
_.Library.Status OnAfterTestSuite | ( | _.Library.String | dir, |
_.Library.String | suite, | ||
_.Library.String | testspec, | ||
qstruct | |||
) |
Called after a test suite is run.
If an error status is returned, it is logged.
|
static |
Called before any unit tests are run.
If an error status is returned, no unit tests are run.
_.Library.Status OnBeforeAutoLoad | ( | _.Library.String | dir, |
_.Library.String | suite, | ||
_.Library.String | testspec, | ||
qstruct | |||
) |
Called before autoload, which occurs before each test suite is run.
If an error status is returned, it is logged and the test suite is not run.
_.Library.Status OnBeforeOneTest | ( | _.Library.String | suite, |
_.Library.String | class, | ||
_.Library.String | method | ||
) |
Called before a test (method starting with "Test" in a class extending <class>UnitTest.TestCase</class>) is run.
If an error status is returned, it is logged and the test is not run.
_.Library.Status OnBeforeTestCase | ( | _.Library.String | suite, |
_.Library.String | class, | ||
_.UnitTest.TestCase | testcase | ||
) |
Called before a test case (class extending <class>UnitTest.TestCase</class>) is run.
If an error status is returned, it is logged and the test case is not run.
_.Library.Status OnBeforeTestSuite | ( | _.Library.String | dir, |
_.Library.String | suite, | ||
_.Library.String | testspec, | ||
qstruct | |||
) |
Called a test suite is run.
If an error status is returned, it is logged and the test suite is not run. This is called after autoload.
|
static |
Runs classes that extend UnitTest.TestCase that contain test methods.
Creates a log on each run, stored in ^UnitTest.Result.
Any of the following command-line arguments can be combined as a single string, such as /noload/norecursive. All are optional.
The first four (debug, load, run, and recursive) are negatable Booleans. They can be turned on with /arg or off by adding no in the front, as /noload or adding =0 to the end, as /load=0.
/debug: Run in debug mode, which causes a break if a test fails. Default is /nodebug.
/load: Load use cases from the specified testspec. Default is /load. If /load and /run are both on, then all loaded classes, routines, and CSP files are deleted after the tests are run. To prevent them from being deleted at the end, load them with DebugLoadTestSuite and run them with DebugRunTestCase.
/run: Run the test suite. Use /norun if you only want to load, but not run, a suite into a namespace. Default is /run.
/recursive: Recurse the specified directory when loading test classes. Default is /recursive.
/display=all: Display extended information when loading exported test class definitions. /display=none displays limited information. Default is /display=all.
/autoload: Automatically load sub-directories with the given name when loading test classes. Default is /autoload=_autoload. When this qualifier is set, classes are loaded from the given sub-directory of the current directory and its ancestors. This makes it possible to use a class in multiple test suites without copying it to each of their directories.
/nodelete: Do not delete loaded classes when the test is complete.
Example of RunTest:
set ^UnitTestRoot = "c:\test" do ##class(UnitTest.Manager).RunTest("sql\sqlprocs") do ##class(UnitTest.Manager).RunTest("sql\sqlprocs","/debug/recursive=0")
Note: If any of your code needs to run in the SYS namespace, zn to the SYS namespace, run the code, then return to another namespace.
|
static |
Same as RunTest, but requires three arguments.
These arguments can be null, as ("","","").
|
static |
Run the tests that are listed within the specified fileName.
The tests within this file have the following format:
<div style="margin-top: 10px; margin-left: 40px;"> [<arg>#</arg> | <arg>//</arg>][<arg>-</arg>]<arg>utPath</arg> <table class="parm-format"> <tr> <td><arg>#</arg> | <arg>//</arg></td> <td><i>Optional</i> - Specifies a comment line</td> </tr> <tr> <td><arg>-</arg></td> <td><i>Optional</i> - Specifies that the <arg>utPath</arg> will be excluded from running</td> </tr> <tr> <td><arg>utPath</arg></td> <td>The directory path of the UnitTest to run, or a path prefix (e.g. SQL\SQLStats) to run all UnitTests within this directory and all sub-directories</td> </tr> </table> </div> <INFO> <b><u>Example</u></b> <b>utFile_with_exclusions.txt</b> // This file contains the following two lists: // 1) A list of UnitTests to exclude from running // 2) A list of UnitTests to run // List all of the excluded UnitTest Paths (<arg>utPath</arg>) first: // NOTE: The negative-sign (<b style="color: red;">-</b><i>utPath</i>) is the exclusion indicator! -SQL\dynamicSQL\DocBookTests -SQL\dynamicSQL\privilege -Classes\Atelier -Classes\Debugger // List all of the UnitTest Paths (<arg>utPath</arg>) to run last: SQL\dynamicSQL Classes <b><u>Invocation</u></b> USER>set tSC=##class(%UnitTest.Manager).RunTestsFromFileList(,"C:\ut\SQLStats_with_exceptions.txt") </INFO> <dl> <dt> <var>globalName</var> <dd> A optional global name, when specified, will be populated with each <arg>utPath</arg> from the given <i>fileName</i>, which is then passed as the 1<sup>st</sup> parameter to the <arg>RunTest(<i>testspec</i>,...)</arg> method for execution. If specified, the value passed to the <i>globalName</i> parameters must have the following format: <INFO style="line-height: 85%;"> INPUT: "^utGlobal" // Where <i>^utGlobal</i> is a valid IRIS Global Name OUTPUT: ^utGloba(<arg>utPath</arg>)="" // e.g. ^utGlobal("SQL\dynamicSQL")="" ^utGlobal("Classes")="" </INFO> </dd> </dt> <dt> <var>fileName</var> <dd>A file path and name, which contains lines of tests in the following format, as specified above: [<arg>#</arg> | <arg>//</arg>][<arg>-</arg>]<arg>utPath</arg><br/><br/></dd> </dt> <dt><i>qualifiers</i> <dd>Any of the following command-line arguments can be combined as a single string, such as <b>/noload/norecursive</b>. All are optional.<br><br> The first four (<b>debug</b>, <b>load</b>, <b>run</b>, and <b>recursive</b>) are negatable Booleans. They can be turned on with <i>/arg</i> or off by adding <b>no</b> in the front, as <b>/noload</b> or adding <b>=0</b> to the end, as <b>/load=0</b>.<br><br> <b>/debug</b>: Run in debug mode, which causes a break if a test fails. Default is <b>/nodebug</b>. <br><br> <b>/load</b>: Load use cases from the specified <i>testspec</i>. Default is <b>/load</b>. If <b>/load</b> and <b>/run</b> are both on, then all loaded classes, routines, and CSP files are deleted after the tests are run. To prevent them from being deleted at the end, load them with <b>DebugLoadTestSuite</b> and run them with <b>DebugRunTestCase</b>.<br><br> <b>/run</b>: Run the test suite. Use <b>/norun</b> if you only want to load, but not run, a suite into a namespace. Default is <b>/run</b>.<br><br> <b>/recursive</b>: Recurse the specified directory when loading test classes. Default is <b>/recursive</b>.<br><br> <b>/display=all</b>: Display extended information when loading exported test class definitions. <b>/display=none</b> displays limited information. Default is <b>/display=all</b>. <br><br> <b>/autoload</b>: Automatically load sub-directories with the given name when loading test classes. Default is <b>/autoload=_autoload</b>. When this qualifier is set, classes are loaded from the given sub-directory of the current directory and its ancestors. This makes it possible to use a class in multiple test suites without copying it to each of their directories.<br><br> <b>/nodelete</b>: Do not delete loaded classes when the test is complete.<br><br> <dt><i>userparam</i> <dd>An arbitrary argument passed in by the caller of the <b>UnitTest</b>. The top node of this variable becomes the value for the <b>UserParam</b> property of the <b>Manager</b>. The first level subscripts and their values are used to populate the <b>UserFields</b> array. </dl> <br><br>
|
static |
Wipe all data from this namespace and all PPG information also.
Useful in cleaning a namespace
before running unit tests. Never do this on a production system!
|
static |
METHOD: addToExcludeGlobal
DESCRIPTION: This method adds the given 'excludeUTPath' to the exclusion global: ^||UnitTest.exclude(0,...) // Master Map ^||UnitTest.exclude("x",$$$UPPER(excludeUTPath)) // Index Map
INVOCATION: This method can be invoked in the following ways: ObjectScript: ##class(UnitTest.Manager).addToExcludeGlobal(...) ..addToExcludeGlobal(...) SQL: N/A
PARAMETERS: excludeUTPath - The directory path of the UnitTest to exclude from running, or a path prefix (e.g. SQL\SQLStats) to exclude all UnitTests within this directory and all sub-directories from running
RETURN Value: The status of this method's invocation;
_.Library.Status deleteLoadedClasses | ( | classLoaded, | |
autoloadArray, | |||
utLoadedArray | |||
) |
METHOD: deleteLoadedClasses
DESCRIPTION: This method deletes all of the classes provided in the following parameter arrays:
INVOCATION: This method can be invoked in the following ways: ObjectScript: ..deleteLoadedClasses(...) SQL: N/A PARAMETERS: classLoaded - A Pass By Reference array of classes that have been loaded into the namespace by the invocation of a given UnitTest autoloadArray - A Pass By Reference array of classes that have been auto-loaded into the namespace by the invocation of a given UnitTest utLoadedArray - A Pass By Reference array of classes that have been loaded into the namespace by the UnitTest during its invocation
|
static |
METHOD: getLoadedClass
DESCRIPTION: Return all of classes that are loaded in the current namespace into the 'classes()' array...
INVOCATION: This method can be invoked in the following ways: ObjectScript: ##class(UnitTest.Manager).getLoadedClass(...) ..getLoadedClass(...) SQL: N/A
PARAMETERS: classes - A Pass By Reference array of classes that are loaded in the current namspace. This array will be populated with classes in the following format: classes=# of classes classes(<class-name>.cls)=""
NOTE: The <class-name> and suffix (.cls) are case-sensitive
skipClasses - A Pass By Reference array of classes that should not be added to the 'classes()' array if found loaded in the current namespace. This array has the following format: skipClasses(<class-name>.cls)=""
EXAMPLE: skipClasses("Sample.Person.cls")="" skipClasses("MRP.Test.cls")=""
NOTE: The <class-name> and suffix (.cls) are case-sensitive
CurrentDir |
The directory that contains the current test.
Debug |
Set to true if the /debug qualifier is on.
Display |
Set to true if the /display=all qualifier is set.
LoadUDL |
Set to true if the /loadudl qualifier is set.
UDL files are .cls, .mac,
.int, .inc, or the upper case extensions.
LoadXML |
Set to true if the /loadxml qualifier is set.
LogIndex |
ReportVariableLeaks |
Set to true if unexpected public variables should trigger an error.
ResultId |
Property to hold results instance slot in ^UnitTest.Manager
|
private |
Private property for internal use only.
UserFields |
Allow users to store additional information, like platform, product version, etc.
for each test.
This information can be later cross-referenced in the result. This array is populated from the first level subscripts of the userparam argument.
UserParam |
Set by the third argument, userparam, of the RunTest method, if specified.