Run Sessions, Logging and Resetting Variables
Logging
By default XJRunner Integration takes its logging settings from the project in the XJPack file that is opened. Creating a new Runner object (to run tests) will always load its logging settings from the project.
XJRunner Integration allows some overriding of these settings. Logging can be switched on or off - either the machine readable formatted version or the plain text version. You can also override the output directory in which log files are created, and use the SetLogFilename method to override the actual name of the file created.
After the log file has been written (see Run Sessions below), you can obtain the name of the file by using the PlainTextLogPath or FormattedLogPath.
Run Sessions, Logging, and Resetting variables
The default behaviour of the XJRunner Integration is that each call to run code (RunTests, RunTest, StartTesting) will use the logging settings of the project (whether loaded from the project file or overridden as above). If logging is being used, the appropriate log file will be created or appended to, and a testing summary box will be inserted in the file at the end of testing if these are enabled. The log file will be closed after the code finishes and the summary has been written.
However, if you wish to make multiple calls to individually run a set of tests (i.e. call RunTest or RunTests multiple times on a unit), then it may be that you do not wish the test summary box to be inserted after every test, or it may be that your log file contains the time of day in the filename and you want to make sure all the tests for a unit appear in one file. For situations like these XJRunner Integration has the concept of a Run Session.
You can open a Run Session using a Runner object, using BeginRunSession and close it using EndRunSession.
Run Sessions have the following effects:
- The same log file is used throughout the session, and written to disk at the end. Logging settings on the Runner instance cannot be changed during the session.
- Any Post-testing function will be run when the session is closed.
- If set, the summary table will be produced when the session is closed.
- XJEase variable values are persisted between calls to run tests within the session, so you can use counters across tests, keep track of whether anything has failed or whether a particular test has run and passed, etc.
Note that you cannot start a Run Session while tests/functions are running, or during an existing Run Session.
XJTAG v4.1.100