A JUnit XML post processing utility, for cleanup and similar purposes
npm install junit-processor
 

A JUnit XML post processing utility, for cleaning up, modifying some data on these reports, or even do some other operations on these reports.
Please consider this highly experimental :)
- remove testcase elements that are marked as skipped, or that have failures or errors
- updates test counters on parent testsuite element, and on root testsuites element if present
- applies patches, to fix/change the JUnit produced by some tools
- validate JUnit XML report against known schemas (e.g., jenkins, ant)
- update testcase elements that match a certain criteria
npm install -g junit-processor
Or just download the repository and include it in your node_modules directly.
``bash
Usage: junit-processor [options]
Options:
-V, --version output the version number
-s, --removeSkipped remove skipped testcases
-e, --removeErrors remove testcases with errors
-f, --removeFailures remove testcases with failures
-x, --schema validate against known schemas
-p, --patches
-o, --out
-d, --debug print debug information
-h, --help display help for command
`
Ahead please find a list of patches that you can apply. Each patch is identified by an id, which is a number.
Example for applying patch 1 on a JUnit XML file:
junit-processor -p 1 some_junit_report.xml
Example for applying patch 1 and 3, in that order, on a JUnit XML file:
junit-processor -p 1,3 some_junit_report.xml
This patch fixes the name attribute of testcase elements of JUnit XML reports produced by Karate DSL, in order to remove the line numbers which may change with time.testcase
The purpose of this patch is to make elements uniquely identifiable, based on their name and classname attributes.
For example,
becomes...
This patch enforces the classname attribute of testcase elements of JUnit XML reports to be junit-processor, even if doesn't exist.
For example,
becomes...
This patch creates one single failure element, in case testcase elements of JUnit XML contain more than one (such as the ones produced by TestComplete). The failure element will have one default message and the inner contents correspond to the concatenation of the original failure elements.
For example,
`xml`
becomes...
`xml`
The property checkpoint failed, because Text does not equal (case-sensitive) "150.0". See Details for additional information.
x1
The test run has stopped because the test item is configured to stop on errors
This patch removes all testcase elements, except the ones that have a property with name "requirements" or "test_key". These properties are usually provided by the xray-junit-extensions project to provide more info on the tests that Xray Test Management will consume.
For example, the first testcase will be included while the second one won't.
`xml
[[ATTACHMENT|test-results/specs-tags-Test-login-page-CALC-1/tmp_screenshot.png]]
]]>
`
After the patch, it becomes...
`xml``
[[ATTACHMENT|test-results/specs-tags-Test-login-page-CALC-1/tmp_screenshot.png]]
]]>
Feel free to submit issues and/or PRs! In lieu of a formal style guide, please follow existing styles.
Please check the following commands that may be useful while developing and testing.
Linting/checking for JS syntax:
npm run lint
Running tests:
npm test
Checking code coverage:
npm run coverage
You can find me on Twitter.
This work was highly based on previous work from junit-merge