JUnit lens
Parses and displays JUnit XML test results summarized by result, with optional filtering to group testcases by properties.
Configuration
The JUnit lens supports optional configuration to group testcases based on their XML properties:
groups- (optional) List of test groups to segregate tests based on properties. Each group entry has:name- Display name for the group section headerselector- XPath property selector expression (currently supportsproperties/property[@name='X' and @value='Y']syntax)collapsed- Boolean, whether the group section starts collapsed (default:false)
Tests matching a group selector are displayed in a separate group section with its name as header and the group’s pass/fail/skip/flaky breakdown. Tests that don’t match any group remain in a default group at the beginning.
Example Configuration
deck:
spyglass:
lenses:
- lens:
name: junit
config:
groups:
- name: "Informing Tests"
selector: "properties/property[@name='lifecycle' and @value='informing']"
collapsed: true
- name: "Upgrade Tests"
selector: "properties/property[@name='type' and @value='upgrade']"
collapsed: false
required_files:
- ^artifacts/junit.*\.xml$
Expected Input
JUnit XML files with optional <properties> elements within <testcase> elements:
<testsuites>
<testsuite>
<testcase classname="MyClass" name="test_something">
<properties>
<property name="lifecycle" value="informing"/>
</properties>
</testcase>
</testsuite>
</testsuites>
Selector Syntax
Currently, only property predicates are supported. The selector syntax is:
properties/property[@name='<property-name>' and @value='<property-value>']
Both @name and @value are optional:
properties/property[@name='lifecycle']- matches any property with name “lifecycle” regardless of valueproperties/property[@value='informing']- matches any property with value “informing” regardless of nameproperties/property[@name='lifecycle' and @value='informing']- matches properties with both name and value
Behavior
- Group selectors are processed in order; a test matches the first group whose selector matches, if any
- Tests that don’t match any group appear in the default group at the top
- Each group section shows its own summary (X/Y Failed, Passed, Skipped, Flaky)
- The
collapsedsetting controls whether the group’s test details are initially hidden
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.