Public Member Functions | |
_.Library.Status | OnBeforeAllTests () |
This method deletes the extent of the <parameter>DATACLASS</parameter> and populates it from the file specified by the <parameter>DATAFILE</parameter> parameter. | |
![]() | |
TestRunScript () | |
This method, which is run automatically by <class>UnitTest.Manager</class>, calls the implementation of <method>runScript</method> supplied by a subclass. 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 | 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 | runScript (_.Library.String scriptfile, _.Library.String outputfile) |
This method reads SQL statements from scriptfile, writing their output to outputfile. More... | |
Static Public Attributes | |
CORRELATIONLIST = None | |
List that correlates XML tags in a data file with classes. More... | |
DATACLASS = None | |
Specifies an XML-enabled class, such as Sample.Person, to be correlated with the <parameter>DATATAG</parameter> in the <parameter>DATAFILE</parameter>. | |
DATAFILE = None | |
XML file, such as person.data, that contains data for the <parameter>DATACLASS</parameter>. More... | |
DATATAG = None | |
Specifies an XML tag in <parameter>DATAFILE</parameter>, such as <person> (angle brackets omitted), to be correlated with the <parameter>DATACLASS</parameter>. | |
DISPLAYELAPSEDTIME = None | |
When <PARAMETER>TIMESCALE</PARAMETER> is a positive number, this parameter is part of the elapsed time message written to output.log. More... | |
DISPLAYSECONDS = None | |
When <PARAMETER>TIMESCALE</PARAMETER> is a positive number, this parameter is part of the elapsed time message written to output.log. More... | |
DISPLAYTESTNAME = None | |
If a test name is specified after the #### terminator in the script, it is written to output.log. More... | |
SHOWPLAN = None | |
Set this parameter to 1 to dump the access plans used by each test in the test script. More... | |
TIMESCALE = None | |
This parameter specifies the number of significant digits used to display elapsed time for each SQL statement to output.log. More... | |
![]() | |
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. | |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
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... | |
The sample class mentioned here (Sample.Person) is part of https://github.com/intersystems/Samples-Data. See Downloading Samples.
This class replays script-driven SQL tests. It provides an implementation of the <method>runScript</method> method that reads and executes SQL statements from the script specified in the <parameter>TESTFILE</parameter> parameter, comparing it to a reference log of expected output. It also provides an implementation of the <method>OnBeforeAllTests</method> method that populates the XML-enabled class under test (<parameter>DATACLASS</parameter>) from <parameter>DATAFILE</parameter>.
To write a test, start by creating a subclass of this class with appropriate values for the <parameter>DATACLASS</parameter>, <parameter>DATAFILE</parameter>, and <parameter>DATATAG</parameter> parameters:
Class Sample.SqlTest extends UnitTest.TestSqlScript { Parameter DATACLASS = "Sample.Person"; Parameter DATAFILE = "person.data"; Parameter DATATAG = "person"; }
Populate the class under test:
Write ##class(Sample.Person).Populate(100)
Export the instances of the class under test to the data file:
Set writer=##class(XML.Writer).New() Set writer.Charset="UTF-8" Set sc=writer.OutputToFile("person.data") Set sc=writer.RootElement("people") Set statement=##class(SQL.Statement).New() Set sc=statement.PrepareClassQuery("Sample.Person","Extent") Set result=statement.Execute() While result.Next(.sc) { Set id=result.Get("ID") Set person=##class(Sample.Person).OpenId(id) Set sc=writer.Object(person,"person") } Set sc=writer.EndRootElement() Set sc=writer.EndDocument()
Create a script file with a series of SQL statements, each terminated by a line starting with "####":
select max(SSN) from Sample.Person
select count(ID) from Sample.Person
Place the following files in a sub-directory of ^UnitTestRoot:
To generate the expected results, run the test with the "reference" parameter:
Do ##class(UnitTest.Manager).RunTest("Sample",,"reference")
It populates the data class, executes the SQL statements, and writes the expected output to reference.log:
SQL> select max(SSN) from Sample.Person Aggregate_1: 992-27-1936:
SQL> select count(ID) from Sample.Person Aggregate_1: 100:
Test count IDs
Subsequent runs without the "reference" parameter will write to output.log, then compare it to reference.log:
Do ##class(UnitTest.Manager).RunTest("Sample")
|
static |
This method reads SQL statements from scriptfile, writing their output to outputfile.
Statements are terminated by a line that starts with "####".
Reimplemented from TestScript.
|
static |
List that correlates XML tags in a data file with classes.
The sample class mentioned here (Sample.Person) is part of https://github.com/intersystems/Samples-Data. See Downloading Samples.
This class replays script-driven SQL tests. It provides an implementation of the <method>runScript</method> method that reads and executes SQL statements from the script specified in the <parameter>TESTFILE</parameter> parameter, comparing it to a reference log of expected output. It also provides an implementation of the <method>OnBeforeAllTests</method> method that populates the XML-enabled class under test (<parameter>DATACLASS</parameter>) from <parameter>DATAFILE</parameter>.
To write a test, start by creating a subclass of this class with appropriate values for the <parameter>DATACLASS</parameter>, <parameter>DATAFILE</parameter>, and <parameter>DATATAG</parameter> parameters:
Class Sample.SqlTest extends UnitTest.TestSqlScript { Parameter DATACLASS = "Sample.Person"; Parameter DATAFILE = "person.data"; Parameter DATATAG = "person"; }
Populate the class under test:
Write ##class(Sample.Person).Populate(100)
Export the instances of the class under test to the data file:
Set writer=##class(XML.Writer).New() Set writer.Charset="UTF-8" Set sc=writer.OutputToFile("person.data") Set sc=writer.RootElement("people") Set statement=##class(SQL.Statement).New() Set sc=statement.PrepareClassQuery("Sample.Person","Extent") Set result=statement.Execute() While result.Next(.sc) { Set id=result.Get("ID") Set person=##class(Sample.Person).OpenId(id) Set sc=writer.Object(person,"person") } Set sc=writer.EndRootElement() Set sc=writer.EndDocument()
Create a script file with a series of SQL statements, each terminated by a line starting with "####":
select max(SSN) from Sample.Person
select count(ID) from Sample.Person
Place the following files in a sub-directory of ^UnitTestRoot:
To generate the expected results, run the test with the "reference" parameter:
Do ##class(UnitTest.Manager).RunTest("Sample",,"reference")
It populates the data class, executes the SQL statements, and writes the expected output to reference.log:
SQL> select max(SSN) from Sample.Person Aggregate_1: 992-27-1936:
SQL> select count(ID) from Sample.Person Aggregate_1: 100:
Test count IDs
Subsequent runs without the "reference" parameter will write to output.log, then compare it to reference.log:
Do ##class(UnitTest.Manager).RunTest("Sample")
Entries are of the form tag1:class1, ..., tagn:classn, with each entry specifying a pair of <parameter>DATATAG</parameter> and <parameter>DATACLASS</parameter> parameter values.
If <parameter>CORRELATIONLIST</parameter>, <parameter>DATACLASS</parameter>, and <parameter>DATATAG</parameter> are all specified, the <parameter>DATATAG</parameter> and <parameter>DATACLASS</parameter> pair are added to the end of the <parameter>CORRELATIONLIST</parameter>.
|
static |
|
static |
When <PARAMETER>TIMESCALE</PARAMETER> is a positive number, this parameter is part of the elapsed time message written to output.log.
Override it to localize the display of elapsed time.
|
static |
When <PARAMETER>TIMESCALE</PARAMETER> is a positive number, this parameter is part of the elapsed time message written to output.log.
Override it to localize the spelling of "seconds."
|
static |
If a test name is specified after the #### terminator in the script, it is written to output.log.
Override this parameter to localize the spelling of "Test."
|
static |
Set this parameter to 1 to dump the access plans used by each test in the test script.
Use this feature when you need to verify plan stability from one release to the next, or when you want to investigate the impact of creating, dropping, or altering an index.
|
static |
This parameter specifies the number of significant digits used to display elapsed time for each SQL statement to output.log.
It can be used as a coarse indicator of differences in the run time of any individual query.
The default value of "" prevents elapsed time information from being displayed at the end of each SQL statement in the test. Setting it to 1 will display the result in seconds. Setting it to 10 will display elapsed time in multiples of 10 seconds. Setting it to 0.1 will display elapsed time to the nearest tenth second.