%UnitTest.Manager
Class %UnitTest.Manager Extends %RegisteredObject [ System = 3 ]
The InterSystems IRIS UnitTest framework is composed of several classes that have the package name (prefix) %UnitTest. Of these classes, the %UnitTest.Manager class is the superclass of the UnitTest infrastructure, and is primarily responsible for the following tasks:
- Individual UnitTest Invocations
- Pre/Post Test Processing
- Runtime Processing & Reporting
- Test/Error Processing & Analysis
- Statistics Collection & Aggregation
- etc. Developers familiar with the xUnit framework should notice a passing resemblance, as these two frameworks share a common testing philosophy. Prior to invoking any of the methods within this class, you must first perform the following setup instructions:
- Set the global ^UnitTestRoot to a valid root directory that contains all of the UnitTest classes from which all UnitTests will be invoked
Example:
set ^UnitTestRoot="C:\MyUnitTests" ; Adding a final slash is optional
Once the setup has been completed, launching a UnitTest is as simple as invoking one the following methods:
- RunTest - Run all tests specified by the testspec parameter and delete all associated test classes after invocation (Unless otherwise specified).
DebugRunTestCase - Run all tests specified by the testspec parameter without deleting the corresponding test classes after invocation. This method requires that all test classes must first be loaded before the first invocation, which can be accomplished by initially invoking the DebugLoadTestSuite method. The RunTest(testspec, spec, userparam) method, more specifically, performs the following tasks:
- Evaluate all of the qualifiers specified by the qspec parameter
- If this parameter contains the qualifiers /cleanup/run/delete, without the /debug qualifier, then all globals, classes, and routines within the current namespace will be recorded before each invocation of the RunOneTestSuite method. After each invocation of this method, the namespace will be purged of all globals, classes and routines, other than those previously recorded
- Evaluate all of the user parameters specified by the userparam parameter
- If this parameter contains the value /log, then all processing information will be logged to the UNITTEST.LOG file which is located in the mgr directory of the IRIS Instance (e.g. $ZU(12))
- Invoke the following method before any UnitTests are run: OnBeforeAllTests
- Collect all UnitTest testsuites (directories) specified by the testspec parameter, and recursively all associated sub-testsuites (sub-directories) (assuming that the /recursive qualifier is on (the default)), whilst skipping all sub-directories whose names begins with an underscore See the notes within the RunTest method for additional details
- For each UnitTest's testsuites collected in the previous step, invoke the RunOneTestSuite method which performs the following tasks:
- Collect all UnitTest classes specified by the dir parameter, along with each class's corresponding test methods when the testspec parameter is defined with the following nomenclature: [-]testsuite [ :[testcase] [ :testmethod ] [ ;[testcase] [ :testmethod ] ]* ]
- Record the start of the testing process based on the specified suite parameter See item (3) in the Important Notes section below for addition details
- Load and compile all relevant files in the directory specified by the dir parameter
* If the /loadxml qualifier is true (the default), then all XML files (*.xml, *.XML) will be loaded
* If the /loadudl qualifier is true (the default), then all UDL files (*.cls, *.mac, *.int, *.inc, *.CLS, *.MAC, *.INT, *.INC) will be loaded
To see the current qualifier values, invoke the following method: do $SYSTEM.OBJ.ShowQualifiers() - For each UnitTest class collected in step (5A) above, invoke the RunOneTestCase method which performs the following tasks:
- Record the start of the testing process based on the specified suite and class parameters See item (3) in the Important Notes section below for addition details
- Instantiate the UnitTest class specified by the class parameter
- Record the current Process Values
- Invoke the following method: OnBeforeTestCase
- Invoke the following method: class.OnBeforeAllTests
- Collect all UnitTest methods from the specified class parameter, which have the following nomenclature: Test* (e.g. Test1 or TestSQL)
- For each method collected in the previous step, perform the following steps:
1. Record the start of the testing process based on the suite, class and method parameters See item (3) in the Important Notes section below for addition details
2. Invoke the following method: OnBeforeOneTest
3. Invoke the following method: class.OnBeforeOneTest
4. Invoke the specified UnitTest method (e.g. Test1 or TestSQL)
5. Invoke the following method: class.OnAfterOneTest
6. Invoke the following method: OnAfterOneTest
7. Record the end of the testing process based on the suite, class and method parameters See item (3) in the Important Notes section below for addition details - Repeat the previous steps (a) through (g) for all of the methods collected in step (VI) above
- Invoke the following method: class.OnAfterAllTests
- Invoke the following method: OnAfterAllTests
- Cleanup and Restore any modified Process Values
- Repeat the previous steps (I) through (XI) for all of the classes collected in (5A) above
- Delete all the classes loaded in step (5C) above
- Record the end of the testing process based on the suite parameter See item (3) in the Important Notes section below for addition details
- Repeat the previous steps (A) through (G) for all testsuites (directories) and all sub-testsuites (sub-directories) collected in step (4) above IMPORTANT NOTES
- Throughout this class, the terms qspec and qualifier will be used interchangeably, as many methods in this class use the qspec parameter, which is a concatenated list of supported system flags and qualifiers documented on the following page: System Flags and Qualifiers The qspec parameter can specify qualifiers in the following format: /[no]
[= ][/[no] [= ]]* - The loading, running and deletion tasks can each be skipped by specifying the following qualifiers respectively: /noload, /norun and /nodelete
- UnitTest results are saved to the following globals. The first global is used by the UnitTest Results CSP Pages, while the second global is used for status processing and debugging:
-
^|ns|UnitTest.Result(id,suite[,class[,method]])=$LIST(...) of Runtime Information ns - The Namespace in which the UnitTest is being invoked (e.g. "USER") id - The value of the Name/Value pair Index within the result URL
-
^IRIS.Temp.UnitState=$LB(suit[,class[,method]])
-
- Evaluate all of the qualifiers specified by the qspec parameter
Properties
LogIndex
Property LogIndex [ Deprecated ];
DEPRECATED. Use the ResultId property.
Debug;
Property Debug;
A Boolean flag that is set to true (1) if the /debug qualifier is enabled (1).
Display;
Property Display;
A Boolean flag that is set to true (1) if the /display=all qualifier is enabled (1).
ReportVariableLeaks;
Property ReportVariableLeaks;
A Boolean flag that is set to true (1) if unexpected public variables should trigger an error.
LoadXML;
Property LoadXML;
A Boolean flag that is set to true (1) if the /loadxml qualifier is enabled (1).
LoadUDL;
Property LoadUDL;
A Boolean flag that is set to true (1) if the /loadudl qualifier is enabled (1). UDL files: *.cls, *.mac, *.int, *.inc, *.CLS, *.MAC, *.INT, *.INC
CurrentDir;
Property CurrentDir;
The directory that contains the current UnitTest.
UserParam
Property UserParam As %String;
Set to the RunTest method's third parameter userparam, if specified as a string.
UserFields
Property UserFields As array Of %String;
Set to the RunTest method's third parameter userparam, if specified as an array. This array is populated from the first level subscripts of the userparam parameter. Allow users to store additional information, like platform, product version, etc. for each UnitTest. This information can be later cross-referenced in the result.
TheStack
Property TheStack [ MultiDimensional, Private ];
Private property for InterSystems INTERNAL USE ONLY!
NSInfo
Property NSInfo [ Internal, MultiDimensional, Private ];
Private property to hold information about the UnitTest's Namespace.
Environment
Property Environment [ Internal, MultiDimensional, Private ];
Private property set primarily in the %OnNew method to hold information about the environment's Process Values. These original values can be restored if changed during the invocation of the UnitTest.
Parallel
Property Parallel As %UnitTest.Parallel [ Internal, Private ];
Private property to hold parallel harness when in use.
ResultId
Property ResultId As %Integer;
Property to hold the Result ID (instance slot) in the ^UnitTest.Manager global.
OriginNS
Property OriginNS As %String [ Internal ];
Internal property to hold the Namespace in which the UnitTest was run.
Methods
RunTest
ClassMethod RunTest(ByRef testspec As %String, qspec As %String, ByRef userparam) As %Status
This method invokes all of the UnitTest methods contained within the classes specified by the testspec parameter. During the invocation of these methods, a running log is maintained within the following global so that it can be inspected by other processes: ^UnitTest.Result
Parameters:
testspec
String: testspec=
Array: testspec(
Global: testspec="^global" (e.g. ^global(
The ^UnitTestRoot global must specify a valid directory whose existence is checked during the invocation of the RunTest(...) method. NOTE-2
By default, the RunTest(...) method will recursively process all sub-directories unless the /norecursive qualifier is passed to the qspec parameter. NOTE-3
If a negative-sign (-) precedes the testsuite, then this directory (and all of its sub-directories) will be excluded from UnitTest invocations.
A
testcase (Optional)
A class, specified in the following format, which extends one of the testing classes (e.g. %UnitTest.TestCase) and contains testing methods: package.class (e.g. Sample.Person)
testmethod (Optional) A testing method name in the following format: Test* (e.g. Test1 or TestFirst) NOTE
If no value is specified for the testspec parameter, then the directory referenced in the ^UnitTestRoot global will be used for the testsuite value.
Any subdirectory whose name begins with an underscore ( _ ) will be skipped.
qspec
This parameter has a name/term that is used interchangeably with the term qualifier, and a value that is a concatenated list of supported system flags and qualifiers documented on the following page: System Flags and Qualifiers This parameter allows the specification of qualifiers in the following format: /[no]
userparam
An arbitrary argument passed in by the caller, which allows for the storage of additional information, like platform, product version, etc. If this parameter is passed a string, then it becomes the value for the UserParam property. If this parameter is passed an array, then the first level subscripts and their values are used to populate the UserFields array property. This information can be later cross-referenced in the result.
Examples:
// --- RunTest(...) Examples --- // --- Setup --- set ^UnitTestRoot="C:\UnitTests\" // --- UnitTest Directories --- // C:\UnitTests\SQL\Embedded // C:\UnitTests\SQL\Dynamic // C:\UnitTests\SQL\ODBC // C:\UnitTests\SQL\JDBC // --- Passing 'testspec' as a String --- set tSC=##class(%UnitTest.Manager).RunTest("SQL\Embedded,SQL\Dynamic") // --- Passing 'testspec' as an Array --- set utSpecs("SQL\Embedded")="" // Alternatively: set utSpecs(1)="SQL\Embedded" set utSpecs("SQL\Dynamic")="" // set utSpecs(2)="SQL\Dynamic" set tSC=##class(%UnitTest.Manager).RunTest(.utSpecs) // --- Passing 'testspec' as a Global --- set ^utSpecs("SQL\Embedded")="" // Alternatively: set ^utSpecs(1)="SQL\Embedded" set ^utSpecs("SQL\Dynamic")="" // set ^utSpecs(2)="SQL\Dynamic" set tSC=##class(%UnitTest.Manager).RunTest("^utSpecs") // --- Passing 'testspec' as an Array (Complex Example) --- set utSpecs("SQL\Embedded:SQL.Embedded:Test1;:Test2")="" set utSpecs("SQL\Dynamic::Test1;:Test2")="" set tSC=##class(%UnitTest.Manager).RunTest(.utSpecs,"/recursive=0") // --- Passing 'testspec' as a String (With Exclusions) --- set tSC=##class(%UnitTest.Manager).RunTest("SQL,-SQL\ODBC,-SQL\JDBC")
NOTE
If any of your code needs to run in the %SYS namespace, change to the %SYS namespace to run that specific code (e.g. ZN "%SYS"), then return to the original namespace for continued code processing.
DebugLoadTestSuite
ClassMethod DebugLoadTestSuite(testsuite As %String = "", qspec As %String = "") As %Status
This method is used to load, but not run, all corresponding UnitTest classes specified by the testsuite parameter. Once the UnitTest classes are loaded by this method, the DebugRunTestCase method can be invoked to run all of the corresponding UnitTests over and over again, without having to reload the UnitTest classes. Developers should use the DebugLoadTestSuite method in conjunction with the DebugRunTestCase method to load all UnitTest classes once, and then run all corresponding UnitTests as often as necessary during the development, debugging and testing process.
DebugRunTestCase
ClassMethod DebugRunTestCase(testsuite As %String = "", testcase As %String = "", qspec As %String = "", testmethod As %String = "", ByRef userparam) As %Status
This method is used to run all UnitTests that were previously loaded by the DebugLoadTestSuite method. Both the testsuite and testcase parameters are required. The testcase parameter is in the form package.class and the testmethod parameter is a method within the UnitTest class. Developers should refer to the DebugLoadTestSuite method to see how these two methods are used in conjunction during the development, debugging and testing process.
PurgeLog
ClassMethod PurgeLog() As %Status
PurgeResult
ClassMethod PurgeResult() As %Status
WipeNamespace
ClassMethod WipeNamespace()
This method will wipe all data from this Namespace in addition to all PPG information. This method is useful in cleaning a Namespace before running all UnitTests. This should never be invoked on a production system!
RunTestSuites
ClassMethod RunTestSuites(%testspec As %String, %qspec, ByRef %userparam) As %Status
This is a private and internal method that is invoked via the RunTest method, but requires a value for each of its three parameters, be it the empty-string ("") or otherwise.
realRunTestSuites
ClassMethod realRunTestSuites(ByRef testspec As %String, qspec, ByRef userparam) As %Status [ Internal ]
This is a private and internal method that is invoked via the RunTestSuites method in order to push an extra frame on the stack so that variables can be _new_ed before performing the bulk of the tasks associated with the RunTest method.
AddSubDirectoryNames
ClassMethod AddSubDirectoryNames(root As %String, testsuite As %String) As %String [ Private ]
LastSubDirectoryName
ClassMethod LastSubDirectoryName(dir As %String) As %String [ Private ]
GetSubDirectories
ClassMethod GetSubDirectories(root, topdir As %String, level As %Integer, suite As %String, ByRef subdirs As %String, qspec As %String, ByRef testskip As %String) As %Status
RunOneTestSuite
Method RunOneTestSuite(dir As %String, suite As %String, testspec As %String, qstruct)
getLoadedClass
ClassMethod getLoadedClass(ByRef classes, ByRef skipClasses) As %Status
This method will 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(...)
- SQL: N/A
Parameters:
classes
A Pass By Reference array of classes that are loaded in the current namespace. 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)="" NOTE: The <class-name> and suffix (.cls) are case-sensitive
Example:
set skipClasses("Sample.Person.cls")="" set skipClasses("MRP.Test.cls")=""
Return Value: The status from the invocation of this method
deleteLoadedClasses
Method deleteLoadedClasses(ByRef classLoaded, ByRef autoloadArray, ByRef utLoadedArray) As %Status [ PublicList = SQLCODE ]
This method deletes all of the classes provided in the following parameter arrays:
- classLoaded()
- autoloadArray()
- utLoadedArray()
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
Return Value: The status from the invocation of this method
RunOneTestCase
Method RunOneTestCase(suite As %String, class As %String, ByRef test As %String = "")
getTestMethods
ClassMethod getTestMethods(class As %String, ByRef methods) As %Status
This internal method spins through all of the methods defined for the given class parameter, which start with the prefix Test, and records/returns this information in the Pass By Reference (PBR) parameter methods as an array sorted/collated in Canonical Order:
methods=# of Methods methods(1..n)=Method Name
GetCurrentPublicVariableSet
ClassMethod GetCurrentPublicVariableSet(ByRef GetCurrentPublicVariableSetset) [ Internal, Private ]
SubtractVariableSet
ClassMethod SubtractVariableSet(ByRef c, ByRef a, ByRef b) [ Internal, Private ]
ValidateVariables
Method ValidateVariables(ByRef preTestVars, ByRef postTestVars) [ Internal, Private ]
ReturnAllowedPublicVariables
ClassMethod ReturnAllowedPublicVariables(ByRef prefix As %String) As %List [ Internal, Private ]
This internal method returns a $LIST(...) of allowable public variables, in addition to the Pass By Reference (PBR) parameter prefix as an as array.
Record
Method Record(ByRef procVals As %String) As %Status
This original internal method is retained for backward compatibility...
RecordProcVals
Method RecordProcVals(ByRef procVals As %String) As %Status
This method records all of the current Process Values within the Pass By Reference (PBR) array parameter procVals...
Cleanup
Method Cleanup(ByRef procVals As %String, kill = 0) As %Status
This original internal method is retained for backward compatibility...
CleanupAllProcVals
Method CleanupAllProcVals(ByRef procVals As %String, kill = 0) As %Status
This internal method will cleanup all General & Specific Process Values that have changed during the invocation of methods within this class, report any differences, and restore those Process Values that have changed to their original value...
CleanupGeneralProcVals
Method CleanupGeneralProcVals(checkLocks = 1) As %Status
This internal method will cleanup all General Process Values that have changed during the invocation of methods within this class, report any differences, and restore those Process Values that have changed to their original value...
CleanupSpecificProcVals
Method CleanupSpecificProcVals(ByRef procVals As %String, kill = 0) As %Status
This internal method will cleanup all Specific Process Values that have changed after the invocation of each UnitTest, which is handled within the RunOneTestCase method, via the following steps:
- Before any UnitTest invocations, Record/Collect the Process Values at the beginning of the RunOneTestCase method by calling the RecordProcVals method
- Compare all Process Values recorded/collected within the array passed to the RecordProcVals method with their current Process Values For each recorded value that differs from its current value, perform the following steps: Create an $$$ERROR($$$GeneralError,) of the Process Value differences
- Restore the Process Value to its originally recorded value
SaveResult
Method SaveResult(duration, ByRef userparam)
LogStateBegin
Method LogStateBegin(testsuite, testcase, testmethod)
LogStateEnd
Method LogStateEnd(duration) As %Integer
This method records the end of a UnitTest and returns the status of its invocation.
GetTestState
ClassMethod GetTestState(level) As %String
LogStateStatus
Method LogStateStatus(status, action)
LogAssert
Method LogAssert(success, action, description, extra, location)
LogMessage
Method LogMessage(message, location)
PrintLine
Method PrintLine(text, level = 0)
PrintErrorLine
Method PrintErrorLine(text, extra)
PrintURL
Method PrintURL()
IsSuccess
Method IsSuccess(suite, case, method, action) As %Boolean
This method is obsolete; Use the GetTestStatus method instead!
GetTestStatus
Method GetTestStatus(suite, case, method, action) As %Integer [ CodeMode = expression ]
This method returns result for a given suite, case, method, and action.
%OnNew
Method %OnNew(initvalue As %RawString) As %Status [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
AcquireSentryLock
Method AcquireSentryLock() [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
ReleaseSentryLock
Method ReleaseSentryLock() [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
DoesHoldSentryLock
Method DoesHoldSentryLock() As %Boolean [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
%OnClose
Method %OnClose() As %Status [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
Root
ClassMethod Root() As %String
This method returns the root directory of the UnitTest hierarchy, which is typically the value stored in the following global: ^UnitTestRoot
AutoLoad
ClassMethod AutoLoad(dir As %String, sub As %String, ByRef classArray As %String, qstruct As %String) As %Status [ Internal ]
This method imports the contents of each sub-directory sub for each directory specified by the Root method down to the dir parameter, and return all of the corresponding classes in the Pass By Reference (PBR) array parameter classArray. This method is part of the implementation for the /autoload qualifier.
ConvertLogData
ClassMethod ConvertLogData(pLogIndex, pResultNamespace = "", pMachine = "", pConfiguration = "", pVersion = "", pUserParam = "", pKillLog = 0) As %Status
This method converts old format data in the ^UnitTestLog global to the new format stored in the ^UnitTest.Result global.
Parameters:
pLogIndex
This is the test instance index in the ^UnitTestLog global.
pResultNamespace
This is the namespace for the ^UnitTest.Result global.
pMachine, pConfiguration, pVersion, pUserParam
The new information collected in the ^UnitTest.Result global, but no longer in the ^UnitTestLog global.
This information can be provided manually when doing the conversion.
The pUserParam parameter is used the same way as the userparam parameter of the RunTest method. The top node of the pUserParam parameter becomes the value of the UserParam property, and the first level subscripts, along with their values, are used to populate the UserFields array property.
ConvertStatus
ClassMethod ConvertStatus(pIndex, pNamespace) As %Status
This method updates the status at each level recursively based on the status of the children. If the pIndex parameter is omitted or passed the empty-string (""), then all of the nodes within the ^|pNamespace|UnitTest.Result(...) global will be converted.
setRecursiveStatus
ClassMethod setRecursiveStatus(pNamespace, pIndex, pSuite, pCase, pMethod) As %Integer
CheckNameStructure
Method CheckNameStructure(dir As %String) [ Internal, Private ]
InterSystems INTERNAL USE ONLY! This method checks UnitTest file names against internal source control requirements. You should not make direct use of this method within your applications. There is no guarantee made about either the behavior or future operation of this method!
RecordNamespace
Method RecordNamespace() As %Status [ Private ]
This is a private and internal method that collects and records all of the globals and routines in the current namespace so that a cleanup can be performed after the UnitTest finished running.
CleanNamespace
Method CleanNamespace() As %Status [ Private ]
This is a private and internal method that cleans the current namespace after the UnitTest finished running. This method will not remove any globals or routines that were recorded during the invocation of the RecordNamespace method.
RunTestsFromFileList
ClassMethod RunTestsFromFileList(globalName As %String = "", fileName As %String = "", qspec As %String, ByRef userparam, sections As %String = "") As %Status
This method runs the UnitTests that are listed within the specified fileName parameter. The tests within this file have the following format:
[# | //] | [
# | // | Optional - Specifies a comment line |
---|---|
[ | Optional - Specifies the beginning of a section of tests. For example [1] or [15] |
- | Optional - Specifies that the utPath will be excluded from running |
utPath | 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 |
Example:
utFile_with_exclusions.txt // 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 (utPath) first: // NOTE: The negative-sign (-utPath) is the exclusion indicator! -SQL\dynamicSQL\DocBookTests -SQL\dynamicSQL\privilege -Classes\Atelier -Classes\Debugger // List all of the UnitTest Paths (utPath) to run last: SQL\dynamicSQL Classes Invocation USER>set tSC=##class(%UnitTest.Manager).RunTestsFromFileList(,"C:\ut\SQLStats_with_exceptions.txt")
globalName
A optional global name, when specified, will be populated with each utPath from the given fileName, which is then passed as the first parameter to the RunTest(testspec,...) method for execution. If specified, the value passed to the globalName parameters must have the following format:
INPUT: "^utGlobal" // Where _^utGlobal_ is a valid IRIS Global Name OUTPUT: ^utGlobal(utPath)="" // e.g. ^utGlobal("SQL\dynamicSQL")="" ^utGlobal("Classes")=""
fileName
A file path and name, which contains lines of tests in the following format, as specified above: [# | //][-]utPath
qspec
This parameter has a name/term that is used interchangeably with the term qualifier, and a value that is a concatenated list of supported system flags and qualifiers documented on the following page: System Flags and Qualifiers This parameter allows the specification of qualifiers in the following format: /[no]
userparam
An arbitrary argument passed in by the caller, which allows for the storage of additional information, like platform, product version, etc. If this parameter is passed a string, then it becomes the value for the UserParam property. If this parameter is passed an array, then the first level subscripts and their values are used to populate the UserFields array property. This information can be later cross-referenced in the result.
sections
An options, comma-delimited list of file sections this call should test. This will not run all the tests listed in the file, but only the tests within the specified [section#] within the file. For example, suppose you file has sections [1], [2], [3], [4], [5], and [6]. If sections="2,4,6" only tests within sections [2], [4], and [6] will be run.
addToExcludeGlobal
ClassMethod addToExcludeGlobal(excludeUTPath As %String = "") As %Status
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(...)
- 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; Otherwise, return an error message if an error occurred
OnAfterSaveResult
Method OnAfterSaveResult(ByRef userparam)
This method is called after the invocation of the SaveResult method to perform any result aggregation tasks required by subtasks.
OnBeforeAllTests
ClassMethod OnBeforeAllTests(manager As %UnitTest.Manager, dir As %String, ByRef qstruct, ByRef userparam) As %Status
This method is called before any UnitTests are run. If an error status is returned, then no UnitTests are run.
OnAfterAllTests
ClassMethod OnAfterAllTests(manager As %UnitTest.Manager, dir As %String, ByRef qstruct, ByRef userparam) As %Status
This method is called after all UnitTests are run. If an error status is returned, then it is logged.
OnBeforeAutoLoad
Method OnBeforeAutoLoad(dir As %String, suite As %String, testspec As %String, ByRef qstruct) As %Status
This method is called before autoload, which occurs before each test suite is run. If an error status is returned, then it is logged and the test suite is not run.
OnBeforeTestSuite
Method OnBeforeTestSuite(dir As %String, suite As %String, testspec As %String, ByRef qstruct) As %Status
This method is called before 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.
OnAfterTestSuite
Method OnAfterTestSuite(dir As %String, suite As %String, testspec As %String, ByRef qstruct) As %Status
This method is called after a test suite is run. If an error status is returned, it is logged.
OnBeforeTestCase
Method OnBeforeTestCase(suite As %String, class As %String, ByRef testcase As %UnitTest.TestCase) As %Status
This method is called before a test case (class extending %UnitTest.TestCase) is run. If an error status is returned, it is logged and the test case is not run.
OnAfterTestCase
Method OnAfterTestCase(suite As %String, class As %String, ByRef testcase As %UnitTest.TestCase) As %Status
This method is called after a test case (class extending %UnitTest.TestCase) is run. If an error status is returned, it is logged.
OnBeforeOneTest
Method OnBeforeOneTest(suite As %String, class As %String, method As %String) As %Status
This method is called before a test (method starting with "Test" in a class extending %UnitTest.TestCase) is run. If an error status is returned, it is logged and the test is not run.
OnAfterOneTest
Method OnAfterOneTest(suite As %String, class As %String, method As %String) As %Status
This method is called after a test (method starting with "Test" in a class extending %UnitTest.TestCase) is run. If an error status is returned, it is logged.
BeforeRunTest
ClassMethod BeforeRunTest(Test As %String) [ Internal ]
AfterRunTest
ClassMethod AfterRunTest(Test As %String) [ Internal ]
UpdateOptions
ClassMethod UpdateOptions() [ Internal ]
RestoreOptions
ClassMethod RestoreOptions() [ Internal ]
ReserveResultId
Method ReserveResultId() [ Internal, Private ]
This is a private and internal method which reserves the UnitTest.Result ID from the ^|$NAMESPACE|UnitTest.Result global. Test suites run under the /parallel option use this value to directly write back their results.
IsParallel
Method IsParallel() As %Boolean [ Internal, Private ]
This is a private and internal method that returns a Boolean value {0|1} which indicates if this %UnitTest.Manager is configured to run suites in parallel?
IsParallelWorker
Method IsParallelWorker() As %Boolean [ Internal, Private ]
This is a private and internal method that returns a Boolean value {0|1} which indicates if this %UnitTest.Manager is inside a worker job running suites in parallel?
QueueSuiteForParallel
Method QueueSuiteForParallel(suite, qspec, userparam) As %Status [ Internal, Private ]
This is a private and internal method that queues suite for parallel execution. The parameters qspec and userparam are similar to those in the RunTestSuites method, except that the userparam parameter will not be Passed By Refence (PBR) into the worker job.
WaitForAllSuitesForParallel
Method WaitForAllSuitesForParallel(ByRef status) As %Status [ Internal, Private ]
This is a private and internal method that waits for all suites queued by QueueSuiteForParallel method to complete. The %UnitTest.Manager expects failed suites to be collected in the Pass By Reference (PBR) array parameter status after the suites have finished running. The ^UnitTest.Result global is scanned for failed suites, which are added as subscripts to the status parameter.
CreateSwarmReviewSSL
Method CreateSwarmReviewSSL() As %Status [ Internal, Private ]
PostSwarmReviewComment
Method PostSwarmReviewComment(comment As %String, ignoreCounter As %Boolean = 0) As %Status [ Internal, Private ]
DeleteSwarmReviewSSL
Method DeleteSwarmReviewSSL() As %Status [ Internal, Private ]