Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-10 20:52:53 +0200
committerMartin Hořeňovský2022-05-10 20:58:02 +0200
commited6b38b096eac9a976e1fdeee5320fa913146af7 (patch)
tree73b19b8d6b01890e2530e570475ffae38f782264
parent5a49285e9cf203dd20b00ac7488a6a3233d60fff (diff)
downloadcatch3-ed6b38b096eac9a976e1fdeee5320fa913146af7.tar.gz
Specialize XML reporter's listener listing
-rw-r--r--src/catch2/reporters/catch_reporter_xml.cpp13
-rw-r--r--src/catch2/reporters/catch_reporter_xml.hpp1
-rw-r--r--tests/CMakeLists.txt12
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")