snitch-org / snitch

Lightweight C++20 testing framework.
Boost Software License 1.0
257 stars 7 forks source link

Add native support for Catch2 XML output #100

Closed cschreib closed 1 year ago

cschreib commented 1 year ago

In a standard build, snitch currently only offers the default reporter. This is human-readable, but not very machine-readable. Other testing frameworks support a machine-readable output (typically XML) so that IDEs and other CI frameworks can understand the output of the framework and display it in their respective UIs.

In Catch2 this is enabled with --reporter xml. The format doesn't appear to be documented, but can be reverse engineered from the source code. Since snitch claims to implement (most of) the Catch2 API, we should probably support the same CLI interface, so that snitch test executables can work in all IDEs and CI frameworks where Catch2 is supported.

Some background discussions:

cschreib commented 1 year ago

@nlohmann You had requested this feature. Good news: the xml_report branch now implements the Catch2 command-line API and XML reporter, so the Catch2 integration in CLion (and other IDEs) should work for snitch too. I have been able to test this with a demo license of CLion (which expires tomorrow), but only in a limited way as I don't really have a workflow in CLion. If you have the chance, could you give it a shot and let me know if it worked to your expectations?

NB: all my attempts to get Catch2 tests to appear in Visual Studio Professional 2022 have failed... Looks like Catch2 integrations aren't as polished as the GTest ones; makes me wonder if supporting the GTest command-line and reporter format would have been a smarter move...

Edit: Actually I got it! I was missing a few critical things ;) I would still appreciate more testing and feedback on the CLion integration though, since I'm not able to test them anymore.