Convert JUnit XML reports to CTRF JSON
npm install junit-to-ctrf> Convert JUnit reports to CTRF reports
This package is useful if there isn't a CTRF reporter available for your test framework. It can be used via the CLI or added as a dependency to your project.
This package can be used via the CLI or added as a dependency to your project.
``sh`
npx junit-to-ctrf path/to/junit.xml
or glob pattern:
`sh`
npx junit-to-ctrf "test-results/*/.xml"
`sh`
npm install junit-to-ctrf
`ts
import { convertJUnitToCTRFReport } from "junit-to-ctrf";
const report = await convertJUnitToCTRFReport("path/to/junit.xml");
`
See API reference for more details.
This package supports the following JUnit XML formats:
- Standard JUnit XML: Traditional JUnit XML format produced by most testing frameworks
- Maven Surefire: JUnit XML format including test retries and flaky test detection
Automatically detects the format based on the XML structure.
-o, --output
-t, --tool
-u, --use-suite-name
-e, --env
Convert a JUnit XML report to the default CTRF report location (ctrf/ctrf-report.json):
`sh`
npx junit-to-ctrf "test-results/*/.xml"
Convert a JUnit XML report to a specified output file:
`sh`
npx junit-to-ctrf "test-results/*/.xml" -o ctrf/combined-report.json
Convert a JUnit XML report and include a tool name in the CTRF report:
`sh`
npx junit-to-ctrf path/to/junit.xml -t ExampleTool
Convert a JUnit XML report and include environment properties in the CTRF report:
`sh`
npx junit-to-ctrf path/to/junit.xml -e appName=MyApp buildName=MyBuild
See CTRF schema for possible environment properties
`sh`
npx junit-to-ctrf path/to/junit.xml -u false
Combine all options in a single command:
`sh``
npx junit-to-ctrf path/to/junit.xml -o path/to/output/ctrf-report.json -t ExampleTool -e appName=MyApp buildName=MyBuild
CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.
Consistency Across Tools: Different testing tools and frameworks often produce reports in varied formats. CTRF ensures a uniform structure, making it easier to understand and compare reports, regardless of the testing tool used.
Language and Framework Agnostic: It provides a universal reporting schema that works seamlessly with any programming language and testing framework.
Facilitates Better Analysis: With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward.
If you find this project useful, consider giving it a GitHub star ⭐ It means a lot to us.