junitify 0.1.14

Takes cargo test JSON and transform to JUnit XML
junitify-0.1.14 is not a library.

junitify

junitify on crates.io pipeline

junitify takes JSON tests from stdin and writes JUnit XML results into stdout, or into a directory specified with --out.

This can be used to integrate with CI/CD platforms that uses JUnit XML format to show tests results in the UI, such as Gitlab.

Installation

cargo install junitify

Example

cargo test -- --format=json -Z unstable-options --report-time | junitify --out tests/

Valgrind (Since 0.1.13)

Since 0.1.13 you can transform Valgrind XML report into JUnit reports, for example:

fish.shell

valgrind --tool=memcheck --xml=yes --xml-file=report.xml (cargo +nightly test -q --message-format=json --no-run | jq -r '.executable | select(. != null)') 
junitify -k valgrind --out tests/ -f report.xml

Non-Zero exit code (Since 0.1.14)

Since 0.1.14, you can now use -z to make junitify exit with a non-zero code when tests fail, also you can use -r to report all tests to stdout.

JUnit XML (Since 0.1.14)

Since 0.1.14, junitify is able to read the JUnit XML produced by itself, in companion with -z and -k, it will print tests results and exit with a non-zero code when there are failed tests.

JUnit XML parser works in the same way as the other parsers, it reads JUnit XML and outputs JUnit XML, it may change its contents and structure, and remove a bunch of values (in case of XMLs that were not generated by junitify).

New XML generator (Since 0.1.14)

Instead of using Handlebars, we now use quick-xml to generate XML, this will help with preserving the original output of tests without applying strange indentation, at the same time it provides a more maintainable code based more on serde.

We will be removing the handlebars dependency in the future.

CI/CD Docker Image

docker pull jonathanxd/junitify:latest

CI/CD Example

You can find an example of CI/CD usage in bindet .gitlab-ci.yml, and see how they look like in one of the pipeline reports.