TeamCity Cloud 2024.03 Help

Reporting Test Metadata

A test run in TeamCity can be associated with some additional information (metadata), complementing test status, execution time, and output. This information can be used to provide extra logs, screenshots, numeric values, tags, and so on.

You can use service messages to report this kind of additional test data in TeamCity and then view it in the TeamCity UI.

Reporting Additional Test Data

Additional test data is reported using the testMetadata service message, with the following attributes:

  • name (optional) is a name of the metadata item, used to distinguish different metadata items for the same test and to show this item in the UI. When omitted, TeamCity autogenerates the name, but does not show it in UI.

  • testName (optional) is the name of the test for which this metadata is generated. If the service message is reported in the middle of the test or immediately after its finish, the testName attribute can be skipped. If the metadata is reported later, it should contain the full test name, including suites and packages in the following format: <suiteName>: <packageName>.<testName> (read more about interpreting test names).

  • value (mandatory) contains the metadata value associated with the test. The max value length is 1024.

  • type (optional) defaults to text unless otherwise specified. The type affects how metadata is stored and how its value is shown in the TeamCity UI.

If the format of the service message is incorrect, a corresponding note about it is written into build log.

The types of data which can be recognised by TeamCity are as follows:

Numeric Values

TeamCity draws a graph with numeric values for the given test. Each subsequent build run adds a new dot to the graph. The Y-axis is formatted according to the "type" parameter value: number, ms (for milliseconds), bytes, or percent.

##teamcity[testMetadata testName='package.Test.testName' name='setUp time' type='ms' value='434.5'] ##teamcity[testMetadata testName='package.Test2.testName' name='Success rate' type='percent' value='91.2'] ##teamcity[testMetadata testName='package.Test3.testName' name='Total amount' type='number' value='54'] ##teamcity[testMetadata testName='package.Test4.testName' name='Package size' type='bytes' value='1048576']

String/Text

##teamcity[testMetadata testName='package.Test.testName' name='some key' value='a text']
##teamcity[testMetadata testName='test.name' name='JetBrains' type='link' value='https://jetbrains.com']

Links to Build Artifacts

##teamcity[testMetadata testName='test.name' type='artifact' value='path/to/catalina.out']

The path to the artifact should be relative to the build artifacts directory, and can reference a file inside an archive:

##teamcity[testMetadata testName='test.name' type='artifact' value='logs.zip!/testTyping/full-log.txt']

When showing links to artifacts, TeamCity shows both the name attribute and the filename of the referenced artifact. If the name was autogenerated, it is not shown.

Images from Artifacts Directory

##teamcity[testMetadata testName='test.name' type='image' value='path/to/screenshot.png']

The path to the image should be relative to the build artifacts directory. When displaying images, TeamCity shows both the name attribute and the filename of the referenced image.

Videos from Artifacts Directory

##teamcity[testMetadata testName='test.name' type='video' value='path/to/screen-capture.mp4']

The path to the video fragment should be relative to the build artifacts directory. When displaying video fragments, TeamCity shows both the name attribute and the filename of the referenced video.

Displaying Additional Test Data

You can view additional test data in various places in the TeamCity web UI.

Additional Test Data for Failed Test

To view additional data for a test, expand the stacktrace: TeamCity shows it before the test failure details in a separate Test Metadata section.

Additional test data for a failed test

Additional Test Data Graph for Numeric Values

To view the test data graph, expand the stacktrace: TeamCity shows it before the test failure details in a separate Test Metadata section.

Additional test data graph for numeric values

Additional Data for Successful Tests

To view additional data for a successful test, go to the Tests tab or the Test History tab: the OK status for a test is now clickable if additional test data is present:

Additional data for successful tests
Last modified: 10 January 2024