Public Member Functions | |
_.Library.Status | CheckErrors () |
Override this method if you are going to check errors with custom code. More... | |
_.Library.Status | CheckResults (_.Library.String Log, _.Library.String New) |
Fill in with code to check the results for the production execution. More... | |
_.Library.Status | CompareFiles (_.Library.String FileName1, _.Library.String FileName2, _.Library.String Dir1, _.Library.String Dir2) |
Compare the contents of two files and return $$$OK if they are equal, or a status code otherwise. More... | |
_.Library.Status | CopyFile (_.Library.String FileName, _.Library.String SourceDir, _.Library.String TargetDir) |
Copy a file from a directory to another directory. More... | |
_.Library.Status | CreateMainDirTree () |
Create a test directory tree that is suitable for generic testing and for HL7 testing. More... | |
_.Library.Status | GetEventLog (_.Library.String type, _.Library.String name, _.Library.Integer baseId, _.Library.String v, _.Library.Integer New) |
Retrieve records from the Interoperability event log, returning them in an array. More... | |
LogErrors (_.Library.Status s, _.Library.String where) | |
Generate log messages with all errors contained in status variable s. | |
_.Library.Status | OnAfterProductionStart () |
Code to run right after the production is started. More... | |
_.Library.Status | OnAfterProductionStop () |
Code to run right after the production is stopped. More... | |
_.Library.Status | OnBeforeProductionStart () |
Code to run right before the production is started. More... | |
_.Library.Status | OnBeforeProductionStop () |
Code to run right before the production is stopped. More... | |
_.Library.String | SubMainDir (AddDirs) |
Helper method to return the normalized directory name for the full directory path composed of. More... | |
![]() | |
_.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... | |
![]() | |
_.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 | |
_.Library.Status | ChangeSetting (_.Library.String production, _.Library.String configName, _.Library.String setting, _.Library.String value, _.Library.Boolean saveToProduction) |
Change the value of a setting for a production item, optionally updating the production class too. More... | |
_.Library.Status | CheckNamespace () |
Check if namespace is Interoperability or HealthShare enabled. | |
_.Library.Status | CreateCredentials (_.Library.String CredId, _.Library.String User, _.Library.String Pw) |
Define credentials. More... | |
_.Library.Status | Debug () |
Run itself in debug mode, without loading/deleting any classes. More... | |
_.Library.Status | Error (_.Library.String msg, _.Library.Status s) |
Compose a general error message as Status with the text message provided. More... | |
Export (_.Library.String dir, _.Library.String suite) | |
Export all classes in the same package to a directory as a set of individual files. More... | |
_.Library.String | GetFullName (_.Library.String Dir, _.Library.String FileName) |
Given a directory and a file name, return a normalized full file name. | |
_.Library.Status | GetSetting (_.Library.String production, _.Library.String configName, _.Library.String setting, _.Library.String value) |
Get the current value of a setting for a production item. More... | |
ListSettings (_.Library.String production, _.Library.String configName) | |
List all existing settings and their values for a given production and config item name. More... | |
_.Library.Status | Run () |
Run itself without loading/deleting any classes. More... | |
_.Library.String | SelectToString (_.Library.String Log, _.Library.String Prop, _.Library.String Value, _.Library.String Del) |
Extract select text information from the event log returned results, and return a delimited string containing. More... | |
_.Library.Status | SendRequest (_.Library.String Name, _.Library.RegisteredObject Req, _.Library.RegisteredObject Resp, _.Library.Boolean GetReply, _.Library.Integer Time) |
Call Interoperability testing service to send a request to a business process or business operation. More... | |
Public Attributes | |
BaseLogId | |
Production's first event log ID. More... | |
DSNToSamples | |
DSN name pointing to namespace SAMPLES. More... | |
DSNToUser | |
DSN name pointing to namespace USER. More... | |
HL7ArchiveDir | |
Normalized directory name for HL7 archive. More... | |
HL7InputDir | |
Normalized directory name for HL7 input. More... | |
HL7OutputDir | |
Normalized directory name for HL7 output. More... | |
HL7WorkDir | |
Normalized directory name for HL7 work. More... | |
InstanceName | |
Instance name. More... | |
LastLogId | |
Last event log ID retrieved for this production execution. More... | |
MachineName | |
Machine name. More... | |
MainDir | |
Normalized root test directory name, which by default is directory TestAutoNNN More... | |
![]() | |
AutoPassword | |
If UnitTest.Manager creates test users specified by AutoUserNames, it will generate a random-string password. More... | |
SkipTest | |
The SkipTest property gets set when a test is being skipped. More... | |
Static Public Attributes | |
IGNOREPRODUCTIONERRORS = None | |
If any errors appear in the Event Log during execution of the production, the test will fail. More... | |
MAXWAIT = None | |
Maximum time in seconds to wait for the production to completely start or stop. More... | |
MINRUN = None | |
Minimum time to let production run before collecting event log entries of type "infouser" and check for results. More... | |
PRODUCTION = None | |
Class name of the production. More... | |
![]() | |
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... | |
![]() | |
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... | |
Unit test base class specialized for testing productions.
Unit tests created based on this class are associated with one production. When the unit test is run, it automatically starts the production, allows it to run for a parameterized time, puts new event log entries in an array and passes control to a method for custom verifications, then stops the production and checks for errors.
The programmer can adjust some parameters, add code to verify results, and use callback methods to handle events before/after start/stop production.
How to use this class:
There are methods to facilitate usage, such as change settings, retrieve additional records from the Interoperability event log, compare files, etc. More details are given below and in the description for each method.
General utility/helper methods available to be used in the test code:
File management utility/helper methods available to be used in the test code (all with normalized names):
<method>CleanUpDirectory</method>: Remove all files from a directory or tree.
The following properties are available:
Utility/helper methods to be used during test development or debugging:
|
static |
Change the value of a setting for a production item, optionally updating the production class too.
Examples:
Set s = ..ChangeSetting([Production], ConfigName, Setting, Value)
Set s = ##class(UnitTest.TestProduction).ChangeSetting(Production, ConfigName, Setting, Value, 1)
The values are validated. Check the return for errors.
_.Library.Status CheckErrors | ( | ) |
Override this method if you are going to check errors with custom code.
It's automatically invoked when parameter <parameter>IGNOREPRODUCTIONERRORS</parameter> = 1.
_.Library.Status CheckResults | ( | _.Library.String | Log, |
_.Library.String | New | ||
) |
Fill in with code to check the results for the production execution.
This method is initialized with a local array containing user created entries of type "Info" from the Event Log, not including the start production/components entries, with the following contents:
Log = last existing seq for array Log()
Log(seq, fieldname) = fieldvalue
To get other entries from the Event Log, or for more information about the array contents, see method <method>GetEventLog</method>.
Return $$$OK in most cases, or an error status if you want to indicate that there was a failure. Remember that failures are automatic when unit test macros are used.
_.Library.Status CompareFiles | ( | _.Library.String | FileName1, |
_.Library.String | FileName2, | ||
_.Library.String | Dir1, | ||
_.Library.String | Dir2 | ||
) |
Compare the contents of two files and return $$$OK if they are equal, or a status code otherwise.
The default for FileName2 is the same name as FileName1 concatenated with _reference before the last file extension.
Examples:
FileName1 = MyFile.txt, default FileName2 = MyFile_Reference.txt
FileName1 = HL7Message_ADTA01, default FileName2 = HL7Message_ADTA01_Reference
The default for Dir1 is the directory name specified by <property>HL7OutputDir</property>.
The default for Dir2 is the unit test directory.
_.Library.Status CopyFile | ( | _.Library.String | FileName, |
_.Library.String | SourceDir, | ||
_.Library.String | TargetDir | ||
) |
Copy a file from a directory to another directory.
This allows for example to place files in
input directories. The default origin directory SourceDir is the unit test directory. The default destination directory TargetDir is the directory name specified by <property>HL7InputDir</property>.
|
static |
Define credentials.
If one already exists with the same Id, it's overwritten. Examples:
Set s = ..CreateCredentials(Id, UserName, Password)
Set s = ##class(UnitTest.TestProduction).CreateCredentials(Id, UserName, Password)
_.Library.Status CreateMainDirTree | ( | ) |
Create a test directory tree that is suitable for generic testing and for HL7 testing.
The default root test directory is defined by property <property>MainDir</property>.
This method does not erase any files or directories if they are already present. To do a cleanup, see method <method>CleanUpDirectory</method>.
This method may be invoked in OnBeforeAllTests() or OnBeforeProductionStart() to initialize the test directory tree.
|
static |
|
static |
Compose a general error message as Status with the text message provided.
If message is the null string, this method returns $$$OK instead.
To append text to an existing error text, pass the status as a second argument.
Examples:
Set status=..Error(message, [oldstatus])
Set status=##class(UnitTest.TestProduction).Error(message, [oldstatus])
|
static |
Export all classes in the same package to a directory as a set of individual files.
If the directory is not specified, then ^UnitTestRoot will be used as a base and the last piece of the package name will be used as the subdirectory name.
If the suite name is not specified, then the last piece of the package name of the current class will be used.
Note that parameter suite is ignored when a directory is specified.
Examples:
Do ##class(MyTestClass).Export()
Do ##class(MyTestClass).Export("D:\Test\MyProductionTests\TempDir")
Do ##class(MyTestClass).Export(,"MySuite")
To do: In production-enabled namespaces, all rules and VDoc schemas whose names start with the package should also be exported.
To do: Think about other kinds of files such as CSP pages.
_.Library.Status GetEventLog | ( | _.Library.String | type, |
_.Library.String | name, | ||
_.Library.Integer | baseId, | ||
_.Library.String | v, | ||
_.Library.Integer | New | ||
) |
Retrieve records from the Interoperability event log, returning them in an array.
type = "info" or "error" or "trace" or "warning" or "alert" or "assert" or "infouser" or "startstop" or "other" name = config name to filter entries (only fetch entries associated with this config name)
Examples:
To get new user entries of type "Info":
Set s = ..GetEventLog("infouser", "", "", .Log, .New)
To get new entries of type "Trace":
Set s = ..GetEventLog("trace", "MyBP", "", .Log, .New)
where New indicates how many new entries were found.
Sample format for the returned array:
Log(1,"ConfigName")="Ens.ScheduleHandler"
Log(1,"ID")="114"
Log(1,"Job")="4768"
Log(1,"SessionId")="8"
Log(1,"SourceClass")="Ens.Director"
Log(1,"SourceMethod")="UpdateProduction"
Log(1,"Stack")=""
Log(1,"Text")="Production 'QDENS.HL7.HL7Routing.Production' is up-to-date."
Log(1,"TimeLogged")="2006-12-05 17:41:06.421"
Log(1,"Type")="Info"
|
static |
Get the current value of a setting for a production item.
Value must be passed by reference. Examples:
Set s = ..GetSetting([Production], ConfigName, Setting, .Value)
Set s = ##class(UnitTest.TestProduction).GetSetting(Production, ConfigName, Setting, .Value)
|
static |
List all existing settings and their values for a given production and config item name.
If a config name is
provided, all settings for this config name are listed. Otherwise all config names are listed. Examples:
Do ##class(MyTestClass).ListSettings(, [configname])
Do ##class(UnitTest.TestProduction).ListSettings(production, [configname])
_.Library.Status OnAfterProductionStart | ( | ) |
Code to run right after the production is started.
Used, for example, to call a method that initiates the test.
If an error status is returned, the test will be aborted and failed and the production will be stopped. So if a non fatal error occurs, you may invoke ..LogErrors(status,"OnAfterProductionStart()") and return $$$OK.
_.Library.Status OnAfterProductionStop | ( | ) |
Code to run right after the production is stopped.
If an error status is returned, the test is failed. If a non fatal error occurs, you may invoke ..LogErrors(status,"OnAfterProductionStop()") and return $$$OK.
_.Library.Status OnBeforeProductionStart | ( | ) |
Code to run right before the production is started.
This is useful to:
If an error status is returned, the test will be aborted and failed. So if a non fatal error occurs, you may invoke ..LogErrors(status,"OnBeforeProductionStart()") and return $$$OK.
_.Library.Status OnBeforeProductionStop | ( | ) |
Code to run right before the production is stopped.
If an error status is returned, the test will be failed and aborted, the production will be stopped. If a non fatal error occurs, you may invoke ..LogErrors(status,"OnBeforeProductionStop()") and return $$$OK.
|
static |
Run itself without loading/deleting any classes.
Example:
Do ##class(MyTestClass).Run()
See also method <method>Debug</method>.
|
static |
Extract select text information from the event log returned results, and return a delimited string containing.
the count followed by selected values, filtering by property/index Prop equals to Value.
|
static |
Call Interoperability testing service to send a request to a business process or business operation.
This is
a way to invoke them directly without creating a dummy business service. The production needs to be enabled for testing.
If no request object type is passed, then type Ens.Request is assumed.
Example:
Set s = ..SendRequest("MyBPName", MyRequestObject, .Response, [GetReply], [Time])
GetReply=1 indicates a response is expected (default is 0).
Time indicates how long to wait for a response in case GetReply=1. Default is 30 secs.
_.Library.String SubMainDir | ( | AddDirs | ) |
Helper method to return the normalized directory name for the full directory path composed of.
the default test directory plus the additional directories, eg. sub1/sub2. The argument containing the additional directories must use slashes ( / ) as the directory delimiter, on all platforms.
|
static |
If any errors appear in the Event Log during execution of the production, the test will fail.
In many cases, errors are expected to happen. In this case, override this parameter. You may also want to check them manually by overriding the method <method>CheckErrors</method>.
|
static |
Maximum time in seconds to wait for the production to completely start or stop.
The default is 10 seconds,
override if necessary.
|
static |
Minimum time to let production run before collecting event log entries of type "infouser" and check for results.
The default is 10 seconds, override if necessary. This varies with the production; some productions only need to run for a little time, and some require more time.
|
static |
Class name of the production.
It must contain the production class name.
BaseLogId |
Production's first event log ID.
DSNToSamples |
DSN name pointing to namespace SAMPLES.
DSNToUser |
DSN name pointing to namespace USER.
HL7ArchiveDir |
Normalized directory name for HL7 archive.
HL7InputDir |
Normalized directory name for HL7 input.
HL7OutputDir |
Normalized directory name for HL7 output.
HL7WorkDir |
Normalized directory name for HL7 work.
InstanceName |
Instance name.
LastLogId |
Last event log ID retrieved for this production execution.
MachineName |
Machine name.
MainDir |
Normalized root test directory name, which by default is directory TestAutoNNN
on the same level as the InterSystems IRIS or HealthShare instance, and where NNN is the build number. To initialize the directory tree see method <method>CreateMainDirTree</method>.