3.5 Created outputs

Several output files are created when tests are executed, and all of them are somehow related to test results. This section discusses what outputs are created, how to configure where they are created, and how to fine-tune their contents.

3.5.1 Different output files

This section explains what different output files can be created and how to configure where they are created. Output files are configured using command line options, which get the path to the output file in question as an argument. A special value NONE (case-insensitive) can be used to disable creating a certain output file.

Output directory

All output files can be set using an absolute path, in which case they are created to the specified place, but in other cases, the path is considered relative to the output directory. The default output directory is the directory where the execution is started from, but it can be altered with the--outputdir (-d) option. The path set with this option is, again, relative to the execution directory, but can naturally be given also as an absolute path. Regardless of how a path to an individual output file is obtained, its parent directory is created automatically, if it does not exist already.

Output file

Output files contain all the test execution results in machine readable XML format. Log, report and xUnit files are typically generated based on them, and they can also be combined and otherwise post-processed with Rebot.

Tip

Starting from Robot Framework 2.8, generating report and xUnit files as part of test execution does not anymore require processing output files. Disabling log generation when running tests can thus save memory.

The command line option --output (-o) determines the path where the output file is created relative to the output directory. The default name for the output file, when tests are run, is output.xml.

When post-processing outputs with Rebot, new output files are not created unless --output option is explicitly used.

Starting from Robot Framework 2.6, it is possible to disable creation of the output file when running tests with a special value NONE. In Robot Framework 2.6 and 2.7 versions this automatically disabled also creating log and report files, but starting from the 2.8 version this is not done anymore. If no outputs are needed, they should all be explicitly disabled using --output NONE --report NONE --log NONE.

Log file

Log files contain details about the executed test cases in HTML format. They have a hierarchical structure showing test suite, test case and keyword details. Log files are needed nearly every time when test results are to be investigated in detail. Even though log files also have statistics, reports are better for getting an higher-level overview.

The command line option --log (-l) determines where log files are created. Unless the special value NONE is used, log files are always created and their default name is log.html.

src/ExecutingTestCases/log_passed.png

An example of beginning of a log file

src/ExecutingTestCases/log_failed.png

An example of a log file with keyword details visible

Report file

Report files contain an overview of the test execution results in HTML format. They have statistics based on tags and executed test suites, as well as a list of all executed test cases. When both reports and logs are generated, the report has links to the log file for easy navigation to more detailed information. It is easy to see the overall test execution status from report, because its background color is green, if all critical tests pass, and bright red otherwise.

The command line option --report (-r) determines where report files are created. Similarly as log files, reports are always created unless NONE is used as a value, and their default name is report.html.

src/ExecutingTestCases/report_passed.png

An example report file of successful test execution

src/ExecutingTestCases/report_failed.png

An example report file of failed test execution

XUnit compatible result file

XUnit result files contain the test execution summary in xUnit compatible XML format. These files can thus be used as an input for external tools that understand xUnit reports. For example, Jenkins continuous integration server supports generating statistics based on xUnit compatible results.

Tip

Jenkins also has a separate Robot Framework plugin.

XUnit output files are not created unless the command line option --xunit (-x) is used explicitly. This option requires a path to the generated xUnit file, relatively to the output directory, as a value.

Because xUnit reports do not have the concept of non-critical tests, all tests in an xUnit report will be marked either passed or failed, with no distinction between critical and non-critical tests. If this is a problem, --xunitskipnoncritical option can be used to mark non-critical tests as skipped. Skipped tests will get a message containing the actual status and possible message of the test case in a format like FAIL: Error message.

Note

--xunitskipnoncritical is a new option in Robot Framework 2.8.

Debug file

Debug files are plain text files that are written during the test execution. All messages got from test libraries are written to them, as well as information about started and ended test suites, test cases and keywords. Debug files can be used for monitoring the test execution. This can be done using, for example, a separate fileviewer.py tool, or in UNIX-like systems, simply with the tail -f command.

Debug files are not created unless the command line option --debugfile (-b) is used explicitly.

Timestamping output files

All output files listed in this section can be automatically timestamped with the option --timestampoutputs (-T). When this option is used, a timestamp in the format YYYYMMDD-hhmmss is placed between the extension and the base name of each file. The example below would, for example, create such output files as output-20080604-163225.xml and mylog-20080604-163225.html:

pybot --timestampoutputs --log mylog.html --report NONE tests.html

Setting titles

The default titles for logs and reports are generated by prefixing the name of the top-level test suite with Test Log or Test Report. Custom titles can be given from the command line using the options --logtitle and --reporttitle, respectively. Underscores in the given titles are converted to spaces automatically.

Example:

pybot --logtitle Smoke_Test_Log --reporttitle Smoke_Test_Report --include smoke my_tests/

Setting background colors

By default the report file has a green background when all the critical tests pass and a red background otherwise. These colors can be customized by using the --reportbackground command line option, which takes two or three colors separated with a colon as an argument:

--reportbackground blue:red

--reportbackground green:yellow:red

--reportbackground #00E:#E00

If you specify two colors, the first one will be used instead of the default green color and the second instead of the default red. This allows, for example, using blue instead of green to make backgrounds easier to separate for color blind people.

If you specify three colors, the first one will be used when all the test succeed, the second when only non-critical tests have failed, and the last when there are critical failures. This feature thus allows using a separate background color, for example yellow, when non-critical tests have failed.

The specified colors are used as a value for the body element's background CSS property. The value is used as-is and can be a HTML color name (e.g. red), a hexadecimal value (e.g. #F00 or #FF0000), or an RGB value (e.g. rgb(255,0,0)). The default green and red colors are specified using hexadecimal values #9F6 and #F33, respectively.

3.5.2 Log levels

Available log levels

Messages in log files can have different log levels. Some of the messages are written by Robot Framework itself, but also executed keywords can log information using different levels. The available log levels are:

FAIL

Used when a keyword fails. Can be used only by Robot Framework itself.

WARN

Used to display warnings. They shown also in the console and in the Test Execution Errors section in log files, but they do not affect the test case status.

INFO

The default level for normal messages. By default, messages below this level are not shown in the log file.

DEBUG

Used for debugging purposes. Useful, for example, for logging what libraries are doing internally. When a keyword fails, a traceback showing where in the code the failure occurred is logged using this level automatically.

TRACE

More detailed debugging level. The keyword arguments and return values are automatically logged using this level.

Setting log level

By default, log messages below the INFO level are not logged, but this threshold can be changed from the command line using the --loglevel (-L) option. This option takes any of the available log levels as an argument, and that level becomes the new threshold level. A special value NONE can also be used to disable logging altogether.

Starting from Robot Framework 2.5.2, it is possible to use the --loglevel option also when post-processing outputs with rebot. This allows, for example, running tests initially with the TRACE level, and generating smaller log files for normal viewing later with the INFO level. By default all the messages included during execution will be included also with rebot. Messages ignored during the execution cannot be recovered.

Another possibility to change the log level is using the BuiltIn keyword Set Log Level in the test data. It takes the same arguments as the --loglevel option, and it also returns the old level so that it can be restored later, for example, in a test teardown.

Visible log level

Starting from Robot Framework 2.7.2, if the log file contains messages at DEBUG or TRACE levels, a visible log level drop down is shown in the upper right corner. This allows users to remove messages below chosen level from the view. This can be useful especially when running test at TRACElevel.

src/ExecutingTestCases/visible_log_level.png

An example log showing the visible log level drop down

By default the drop down will be set at the lowest level in the log file, so that all messages are shown. The default visible log level can be changed using --loglevel option by giving the default after the normal log level separated by a colon:

--loglevel DEBUG:INFO

In the above example, tests are run using level DEBUG, but the default visible level in the log file is INFO.

3.5.3 Splitting logs

Normally the log file is just a single HTML file. When the amount of he test cases increases, the size of the file can grow so large that opening it into a browser is inconvenient or even impossible. Starting from Robot Framework 2.6, it is possible to use the --splitlog option to split parts of the log into external files that are loaded transparently into the browser when needed.

The main benefit of splitting logs is that individual log parts are so small that opening and browsing the log file is possible even if the amount of the test data is very large. A small drawback is that the overall size taken by the log file increases.

Technically the test data related to each test case is saved into a JavaScript file in the same folder as the main log file. These files have names such as log-42.js where log is the base name of the main log file and 42 is an incremented index.

Note

When copying the log files, you need to copy also all the log-*.js files or some information will be missing.

3.5.4 Configuring statistics

There are several command line options that can be used to configure and adjust the contents of the Statistics by Tag, Statistics by Suite and Test Details by Tag tables in different output files. All these options work both when executing test cases and when post-processing outputs.

Configuring displayed suite statistics

When a deeper suite structure is executed, showing all the test suite levels in the Statistics by Suite table may make the table somewhat difficult to read. By default all suites are shown, but you can control this with the command line option --suitestatlevel which takes the level of suites to show as an argument:

--suitestatlevel 3

Including and excluding tag statistics

When many tags are used, the Statistics by Tag table can become quite congested. If this happens, the command line options --tagstatinclude and --tagstatexclude can be used to select which tags to display, similarly as --include and --exclude are used to select test cases:

--tagstatinclude some-tag --tagstatinclude another-tag

--tagstatexclude owner-*

--tagstatinclude prefix-* --tagstatexclude prefix-13

Generating combined tag statistics

The command line option --tagstatcombine can be used to generate aggregate tags that combine statistics from multiple tags. The combined tags are specified using tag patterns where * and ? are supported as wildcards and AND, OR and NOT operators can be used for combining individual tags or patterns together.

The following examples illustrate creating combined tag statistics using different patterns, and the figure below shows a snippet of the resulting Statistics by Tag table:

--tagstatcombine owner-*

--tagstatcombine smokeANDmytag

--tagstatcombine smokeNOTowner-janne*

src/ExecutingTestCases/tagstatcombine.png

Examples of combined tag statistics

As the above example illustrates, the name of the added combined statistic is, by default, just the given pattern. If this is not good enough, it is possible to give a custom name after the pattern by separating them with a colon (:). Possible underscores in the name are converted to spaces:

--tagstatcombine prio1ORprio2:High_priority_tests

You can add external links to the Statistics by Tag table by using the command line option --tagstatlink. Arguments to this option are given in the format tag:link:name, where tag specifies the tags to assign the link to, link is the link to be created, and name is the name to give to the link.

tag may be a single tag, but more commonly a simple pattern where * matches anything and ? matches any single character. When tag is a pattern, the matches to wildcards may be used in link and title with the syntax %N, where "N" is the index of the match starting from 1.

The following examples illustrate the usage of this option, and the figure below shows a snippet of the resulting Statistics by Tag table when example test data is executed with these options:

--tagstatlink mytag:http://www.google.com:Google

--tagstatlink jython-bug-*:http://bugs.jython.org/issue_%1:Jython-bugs

--tagstatlink owner-*:mailto:%[email protected]?subject=Acceptance_Tests:Send_Mail

src/ExecutingTestCases/tagstatlink.png

Examples of links from tag names

Adding documentation to tags

Tags can be given a documentation with the command line option --tagdoc, which takes an argument in the format tag:doc. tag is the name of the tag to assign the documentation to, and it can also be a simple pattern matching multiple tags. doc is the assigned documentation. Underscores in the documentation are automatically converted to spaces and it can also contain HTML formatting.

The given documentation is shown with matching tags in the Test Details by Tag table, and as a tool tip for these tags in the Statistics by Tag table. If one tag gets multiple documentations, they are combined together and separated with an ampersand.

Examples:

--tagdoc mytag:My_documentation

--tagdoc regression:See_http://info.html

--tagdoc owner-*:Original_author

3.5.5 Removing and flattening keywords

Most of the content of output files comes from keywords and their log messages. When creating higher level reports, log files are not necessarily needed at all, and in that case keywords and their messages just take space unnecessarily. Log files themselves can also grow overly large, especially if they contain for loops or other constructs that repeat certain keywords multiple times.

In these situations, command line options --removekeywords and --flattenkeywords can be used to dispose or flatten unnecessary keywords. They can be used both when executing test cases and when post-processing outputs. When used during execution, they only affect the log file, not the XML output file. With rebot they affect both logs and possibly generated new output XML files.

Removing keywords

The --removekeywords option removes keywords and their messages altogether. It has the following modes of operation, and it can be used multiple times to enable multiple modes. Keywords that contain warnings are not removed except when using the ALL mode.

ALL

Remove data from all keywords unconditionally.

PASSED

Remove keyword data from passed test cases. In most cases, log files created using this option contain enough information to investigate possible failures.

FOR

Remove all passed iterations from for loops except the last one.

WUKS

Remove all failing keywords inside BuiltIn keyword Wait Until Keyword Succeeds except the last one.

NAME:<pattern>

Remove data from all keywords matching the given pattern regardless the keyword status. The pattern is matched against the full name of the keyword, prefixed with the possible library or resource file name. The pattern is case, space, and underscore insensitive, and it supports simple patterns with * and ? as wildcards.

Examples:

rebot --removekeywords all --output removed.xml output.xml

pybot --removekeywords passed --removekeywords for tests.txt

pybot --removekeywords name:HugeKeyword --removekeywords name:resource.* tests.txt

Removing keywords is done after parsing the output file and generating an internal model based on it. Thus it does not reduce memory usage as much as flattening keywords.

Note

The support for using --removekeywords when executing tests as well as FOR and WUKS modes were added in Robot Framework 2.7.

Note

NAME:<pattern> mode was added in Robot Framework 2.8.2.

Flattening keywords

The --flattenkeywords option flattens matching keywords. In practice this means that matching keywords get all log messages from their child keywords, recursively, and child keywords are discarded otherwise. Flattening supports the following modes:

FOR

Flatten for loops fully.

FORITEM

Flatten individual for loop iterations.

NAME:<pattern>

Flatten keywords matching the given pattern. Pattern matching rules are same as when removing keywords using NAME:<pattern> mode.

Examples:

pybot --flattenkeywords name:HugeKeyword --flattenkeywords name:resource.* tests.txt

rebot --flattenkeywords foritem --output flattened.xml original.xml

Flattening keywords is done already when the output file is parsed initially. This can save a significant amount of memory especially with deeply nested keyword structures.

Note

Flattening keywords is a new feature in Robot Framework 2.8.2, and FOR and FORITEM modes were added in Robot Framework 2.8.5.

3.5.6 Setting start and end time of execution

When combining outputs using rebot, it is possible to set the start and end time of the combined test suite using the options --starttime and --endtime, respectively. This is convenient, because by default, combined suites do not have these values. When both the start and end time are given, the elapsed time is also calculated based on them. Otherwise the elapsed time is got by adding the elapsed times of the child test suites together.

Starting from Robot Framework 2.5.6, it is also possible to use the above mentioned options to set start and end times for a single suite when using rebot. Using these options with a single output always affects the elapsed time of the suite.

Times must be given as timestamps in the format YYYY-MM-DD hh:mm:ss.mil, where all separators are optional and the parts from milliseconds to hours can be omitted. For example, 2008-06-11 17:59:20.495 is equivalent both to 20080611-175920.495 and 20080611175920495, and also mere20080611 would work.

Examples:

rebot --starttime 20080611-17:59:20.495 output1.xml output2.xml

rebot --starttime 20080611-175920 --endtime 20080611-180242 *.xml

rebot --starttime 20110302-1317 --endtime 20110302-11418 myoutput.xml

3.5.7 System log

Robot Framework has its own plain-text system log where it writes information about

  • Processed and skipped test data files
  • Imported test libraries, resource files and variable files
  • Executed test suites and test cases
  • Created outputs

Normally users never need this information, but it can be useful when investigating problems with test libraries or Robot Framework itself. A system log is not created by default, but it can be enabled by setting the environment variable ROBOT_SYSLOG_FILE so that it contains a path to the selected file.

A system log has the same log levels as a normal log file, with the exception that instead of FAIL it has the ERROR level. The threshold level to use can be altered using the ROBOT_SYSLOG_LEVEL environment variable like shown in the example below. Possible unexpected errors and warnings are written into the system log in addition to the console and the normal log file.

#!/bin/bash

export ROBOT_SYSLOG_FILE=/tmp/syslog.txt

export ROBOT_SYSLOG_LEVEL=DEBUG

pybot --name Syslog_example path/to/tests

results matching ""

    No results matching ""