IBM Support

Logging test output to file

Question & Answer


Question

Can you divert IBM Rational Integration Tester (RIT) test console output to your own file?

Cause

You are running RIT tests and wish to save certain messages to a file for future use.

Answer

When you run tests as part of test suites and test cycles, the test console including message validation errors is saved to the project results database.
Stubs also log to the results database if they are configured to do so.
It is not possible to divert individual pieces of output to a log file. For example you cannot capture a message validation error or a Subscribe time-out and send that text to a file.

If you run tests on the command line you can divert the whole of the output to a file using the operating system redirection mechanism. See the following command:

Runtests -project C:\Tests\MyProject.ghp -run Tests/MyTest -environment IBM > C:\logs\mylogFile.log

The following command also sends RIT error output to a separate file using the file handle number 2 or STDERR. An example of this would be the warning message telling you that no project database is configured.

Runtests -project C:\Tests\MyProject.ghp -run Tests/MyTest -environment IBM > C:\logs\mylogFile.log 2 > C:\logs\myErrorFile.log

You can use the Log test action to create your own log file and write your own messages to it. You can include the content of test tags in your output.

You can also use the Function test action with ECMAScript with the Java FileWriter object to perform more complex file manipulation.
Here is a simple example script that creates a file and writes some text to it:

var APPEND = true;



var logger = new java.io.FileWriter("C:\\Temp\\myLog.log", APPEND);

logger.write("Hello\n");

logger.flush();
logger.close();


Remember to use either the flush() or close() methods to force the data to be written to the file.

See also the technote Using ECMAScript with tags in IBM Rational Integration Tester for further details of accessing tag values.

[{"Product":{"code":"SSBLQQ","label":"IBM Rational Test Workbench"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Rational Integration Tester","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF022","label":"OS X"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.0;8.5;8.6","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
29 September 2018

UID

swg21683201