I can run a Catch executable with -o junit --output catch_results.xml
to generate an xml report.
Is there some way to both generate an xml report, and also have the console output?
I can run a Catch executable with -o junit --output catch_results.xml
to generate an xml report.
Is there some way to both generate an xml report, and also have the console output?
Assuming you are asking for having a JUnit output in a file and the standard console reporter at stdout, there is no way to do that.
Catch2 used to support multiple reporters, but there was no support for having them write their output to separate files/outputs, which meant that the feature was unusable and was removed until some point in the future.
You can implement your own Listener
.
A Listener
can implement 'event handlers' for certain events (test suite start/end, test case start/end, ...). In those event handlers you can output to the console (use printf
instead of cout
as cout
can be intercepted by the test runner).
And, most importantly, your Listener
can run in combination with a reporter.
https://github.com/catchorg/Catch2/blob/master/docs/event-listeners.md
If you are able to move to C++14 and update Catch to v3.x then it is quite easy.
Just call
myTest.exe --reporter JUnit::out=result-junit.xml --reporter console::out=-::colour-mode=ansi
This will print the end result to the command line, and the JUnit result to result-junit.xml
For more information about the reporters go to Catch2 reporters .
Moving from Catch2 to Catch3 is also not so painful. Migrating for v2 to v3. Side note: you can still use the one header-ish version, see migration option 1.