|
| 1 | +**JUnit to CTRF v0.0.10-next.0** |
| 2 | + |
| 3 | +*** |
| 4 | + |
| 5 | +# Convert JUnit XML to CTRF JSON |
| 6 | + |
| 7 | +> Convert JUnit reports to CTRF reports |
| 8 | +
|
| 9 | +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. |
| 10 | + |
| 11 | +<div align="center"> |
| 12 | +<div style="padding: 1.5rem; border-radius: 8px; margin: 1rem 0; border: 1px solid #30363d;"> |
| 13 | +<span style="font-size: 23px;">💚</span> |
| 14 | +<h3 style="margin: 1rem 0;">CTRF tooling is open source and free to use</h3> |
| 15 | +<p style="font-size: 16px;">You can support the project with a follow and a star</p> |
| 16 | + |
| 17 | +<div style="margin-top: 1.5rem;"> |
| 18 | +<a href="https://github.com/ctrf-io/junit-to-ctrf"> |
| 19 | +<img src="https://img.shields.io/github/stars/ctrf-io/junit-to-ctrf?style=for-the-badge&color=2ea043" alt="GitHub stars"> |
| 20 | +</a> |
| 21 | +<a href="https://github.com/ctrf-io"> |
| 22 | +<img src="https://img.shields.io/github/followers/ctrf-io?style=for-the-badge&color=2ea043" alt="GitHub followers"> |
| 23 | +</a> |
| 24 | +</div> |
| 25 | +</div> |
| 26 | + |
| 27 | +<p style="font-size: 14px; margin: 1rem 0;"> |
| 28 | +Maintained by <a href="https://github.com/ma11hewthomas">Matthew Thomas</a><br/> |
| 29 | +Contributions are very welcome! <br/> |
| 30 | +Explore more <a href="https://www.ctrf.io/integrations">integrations</a> |
| 31 | +</p> |
| 32 | +</div> |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +As a dependency: |
| 37 | + |
| 38 | +```sh |
| 39 | + |
| 40 | +``` |
| 41 | + |
| 42 | +## CLI Usage |
| 43 | + |
| 44 | +```sh |
| 45 | +npx junit-to-ctrf path/to/junit.xml |
| 46 | +``` |
| 47 | + |
| 48 | +or glob pattern: |
| 49 | + |
| 50 | +```sh |
| 51 | +npx junit-to-ctrf "test-results/**/*.xml" |
| 52 | +``` |
| 53 | + |
| 54 | +## Options |
| 55 | + |
| 56 | +`-o`, `--output` <output>: Output directory and filename for the CTRF report. If not provided, defaults to ctrf/ctrf-report.json. |
| 57 | + |
| 58 | +`-t`, `--tool` <toolName>: Tool name to include in the CTRF report. |
| 59 | + |
| 60 | +`-u`, `--use-suite-name` <useSuiteName>: Use suite name in the test name, defaults to true. |
| 61 | + |
| 62 | +`-e`, `--env` <envProperties>: Environment properties to include in the CTRF report. Accepts multiple properties in the format KEY=value. |
| 63 | + |
| 64 | +## Examples |
| 65 | + |
| 66 | +Convert a JUnit XML report to the default CTRF report location (ctrf/ctrf-report.json): |
| 67 | + |
| 68 | +```sh |
| 69 | +npx junit-to-ctrf "test-results/**/*.xml" |
| 70 | +``` |
| 71 | + |
| 72 | +### Specify Output File |
| 73 | + |
| 74 | +Convert a JUnit XML report to a specified output file: |
| 75 | + |
| 76 | +```sh |
| 77 | +npx junit-to-ctrf "test-results/**/*.xml" -o ctrf/combined-report.json |
| 78 | +``` |
| 79 | + |
| 80 | +### Include Tool Name |
| 81 | + |
| 82 | +Convert a JUnit XML report and include a tool name in the CTRF report: |
| 83 | + |
| 84 | +```sh |
| 85 | +npx junit-to-ctrf path/to/junit.xml -t ExampleTool |
| 86 | +``` |
| 87 | + |
| 88 | +### Include Environment Properties |
| 89 | + |
| 90 | +Convert a JUnit XML report and include environment properties in the CTRF report: |
| 91 | + |
| 92 | +```sh |
| 93 | +npx junit-to-ctrf path/to/junit.xml -e appName=MyApp buildName=MyBuild |
| 94 | +``` |
| 95 | + |
| 96 | +See [CTRF schema](https://www.ctrf.io/docs/schema/environment) for possible environment properties |
| 97 | + |
| 98 | +### Exclude Suite Name |
| 99 | + |
| 100 | +```sh |
| 101 | +npx junit-to-ctrf path/to/junit.xml -u false |
| 102 | +``` |
| 103 | + |
| 104 | +### Full Command |
| 105 | + |
| 106 | +Combine all options in a single command: |
| 107 | + |
| 108 | +```sh |
| 109 | +npx junit-to-ctrf path/to/junit.xml -o path/to/output/ctrf-report.json -t ExampleTool -e appName=MyApp buildName=MyBuild |
| 110 | +``` |
| 111 | + |
| 112 | +## API reference |
| 113 | + |
| 114 | +## What is CTRF? |
| 115 | + |
| 116 | +CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports. |
| 117 | + |
| 118 | +**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. |
| 119 | + |
| 120 | +**Language and Framework Agnostic:** It provides a universal reporting schema that works seamlessly with any programming language and testing framework. |
| 121 | + |
| 122 | +**Facilitates Better Analysis:** With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward. |
| 123 | + |
| 124 | +## Support Us |
| 125 | + |
| 126 | +If you find this project useful, consider giving it a GitHub star ⭐ It means a lot to us. |
0 commit comments