Parser Templates
About
With Zephyr Enterprise, you can run tests that use automated test frameworks and tools: JUnit, TestComplete, SoapUI, Selenium, and others. These tools generate test reports in XML formats. Zephyr uses special templates to extract data from these reports and adds them to its test logs properly. We call these templates parser templates.
Zephyr comes with a number of pre-configured parser templates for processing results of most popular test tools and frameworks. You can also customize this collection by creating templates for other existing frameworks: both ready-made products available on the market, as well as for your home-grown solutions.
How it works
The templates work at the end of test runs.
Jenkins
If you run tests using Jenkins, you can then add the Publish test results to Zephyr Enterprise post-build step to your Jenkins job (the step is provided by the Zephyr plugin for Jenkins). In step properties, you specify the test framework and the XML file holding test results:
Zephyr will use a template that matches the specified framework (JUnit in the image above) to convert test results from the specified XML file into the format adopted by Zephyr. It will go through the XML nodes and for every test case it finds in it, it will create a Test Execution item in Zephyr.
ZBot
If you use ZBot for test runs, you have similar settings to specify the test framework and test result file for parsing:
What is a parser template?
A template is a JSON structure that specifies conversion rules for the data in the XML test reports to the format that Zephyr “understands”. Below is a template for JUnit reports:
Template:
JUnit report:
Notes:
The field names (
status
,statusExistPass
, and others) specify Zephyr’s properties of a test run. The field values specify these properties’ values.The values can be constants (strings, numbers, boolean values), or they can be references to values of XML reports. To specify an XML value, you use a syntax like this:
${testsuite.testcase:classname}
The expression starts with
$
and is followed by an element and the attribute names enclosed in curly braces. In the example above,testsuite
andtestcase
are element names, andclassname
is an attribute. It is separated from elements with a colon; elements are separated by periods:
If needed, you can concatenate substrings in a value. For example:
Class name: ${testsuite.testcase:classname}, test case: ${testsuite.testcase:name}
For information on Zephyr properties (
status
,statusExistPass
, and others), see Parser Template Syntax.
An XML file can have results for multiple test cases. Zephyr will use one template file to extract the information for all of them.
Create, edit and delete templates
To create, edit or delete templates, you send requests to the Zephyr Enterprise API. See the complete description of available operations.
Template syntax
See Parser Template Syntax. This page will also explain how Zephyr checks the test result data to determine if a test passed or fail, and will provide examples of solving typical tasks.