diff options
| author | Martin Hořeňovský | 2022-05-10 20:52:53 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-05-10 20:58:02 +0200 |
| commit | ed6b38b096eac9a976e1fdeee5320fa913146af7 (patch) | |
| tree | 73b19b8d6b01890e2530e570475ffae38f782264 | |
| parent | 5a49285e9cf203dd20b00ac7488a6a3233d60fff (diff) | |
| download | catch3-ed6b38b096eac9a976e1fdeee5320fa913146af7.tar.gz | |
Specialize XML reporter's listener listing
| -rw-r--r-- | src/catch2/reporters/catch_reporter_xml.cpp | 13 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_xml.hpp | 1 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 12 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index b8b93235..1e5def41 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -259,6 +259,19 @@ namespace Catch { } } + void XmlReporter::listListeners(std::vector<ListenerDescription> const& descriptions) { + auto outerTag = m_xml.scopedElement( "RegisteredListeners" ); + for ( auto const& listener : descriptions ) { + auto inner = m_xml.scopedElement( "Listener" ); + m_xml.startElement( "Name", XmlFormatting::Indent ) + .writeText( listener.name, XmlFormatting::None ) + .endElement( XmlFormatting::Newline ); + m_xml.startElement( "Description", XmlFormatting::Indent ) + .writeText( listener.description, XmlFormatting::None ) + .endElement( XmlFormatting::Newline ); + } + } + void XmlReporter::listTests(std::vector<TestCaseHandle> const& tests) { auto outerTag = m_xml.scopedElement("MatchingTests"); for (auto const& test : tests) { diff --git a/src/catch2/reporters/catch_reporter_xml.hpp b/src/catch2/reporters/catch_reporter_xml.hpp index b557bfba..573f9321 100644 --- a/src/catch2/reporters/catch_reporter_xml.hpp +++ b/src/catch2/reporters/catch_reporter_xml.hpp @@ -51,6 +51,7 @@ namespace Catch { void benchmarkFailed( StringRef error ) override; void listReporters(std::vector<ReporterDescription> const& descriptions) override; + void listListeners(std::vector<ListenerDescription> const& descriptions) override; void listTests(std::vector<TestCaseHandle> const& tests) override; void listTags(std::vector<TagInfo> const& tags) override; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fa63e7c0..af4ca28e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -219,7 +219,17 @@ add_test(NAME List::Listeners::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-listeners ) - +add_test(NAME List::Listeners::XmlOutput + COMMAND + $<TARGET_FILE:SelfTest> + --list-listeners + --reporter xml +) +set_tests_properties(List::Listeners::XmlOutput + PROPERTIES + PASS_REGULAR_EXPRESSION "<RegisteredListeners>" + FAIL_REGULAR_EXPRESSION "Registered listeners:" +) add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions "An empty test with no assertions") set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case") |