catchorg / Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
https://discord.gg/4CWS9zD
Boost Software License 1.0
18.67k stars 3.05k forks source link

Support multiple reporters for `catch_discover_tests` #2824

Open brianjmaher opened 8 months ago

brianjmaher commented 8 months ago

Description When running Catch2 tests from the command line, it's possible to specify and configure multiple reporters, e.g. console with colors and JUnit, to make it easy to for a human to use console output and easy for a CI/CD system to digest JUnit results. However, when using the catch_discover_tests CMake utility, only one reporter can be provided. Is it possible it could be extended to support multiple reporters, or have some other way to get both colorful console output and JUnit output?

horenmar commented 8 months ago

If anyone wants to poke into this, note that to have multiple reporters active, they have to have different output destinations, or use the extended reporter specification to explicitly target the same output. Currently discover_tests only accepts one reporter and either lets it write to stdout, or it generates output filename for the tests based on the tests's name and prefix/suffix/folder arguments to the script.

For a general solution for N reporters, the script would have to accept "templated" reporter specs and understand how to rewrite them for the actual tests. For solution specific to this issue, there would likely need to be an extra argument along the lines of STDOUT_REPORTER, that would be handled specially to target stdout, and the default REPORTER argument would keep the current semantics.