mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 11:23:29 +01:00
Refactor noMatchingTestCases and skipTests reporter methods
They now take `StringRef` as the argument, and are virtual only in the basic interface. Also cleaned out the various reporters and their overrides of these members which were often empty or delegating up.
This commit is contained in:
parent
10fb93cce8
commit
013edc208b
@ -171,9 +171,8 @@ namespace Catch {
|
||||
return m_preferences;
|
||||
}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& spec ) = 0;
|
||||
|
||||
virtual void reportInvalidArguments(std::string const&) {}
|
||||
virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0;
|
||||
virtual void reportInvalidArguments( StringRef invalidArgument ) = 0;
|
||||
|
||||
virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
|
||||
|
||||
|
@ -229,7 +229,8 @@ namespace Catch {
|
||||
std::vector<ReporterDescription> const& ) {}
|
||||
void EventListenerBase::listTests( std::vector<TestCaseHandle> const& ) {}
|
||||
void EventListenerBase::listTags( std::vector<TagInfo> const& ) {}
|
||||
void EventListenerBase::noMatchingTestCases( std::string const& ) {}
|
||||
void EventListenerBase::noMatchingTestCases( StringRef ) {}
|
||||
void EventListenerBase::reportInvalidArguments( StringRef ) {}
|
||||
void EventListenerBase::testRunStarting( TestRunInfo const& ) {}
|
||||
void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {}
|
||||
void EventListenerBase::testCasePartialStarting(TestCaseInfo const&, uint64_t) {}
|
||||
|
@ -258,8 +258,8 @@ private:
|
||||
return "Reports test results on a single line, suitable for IDEs";
|
||||
}
|
||||
|
||||
void CompactReporter::noMatchingTestCases( std::string const& spec ) {
|
||||
stream << "No test cases matched '" << spec << "'\n";
|
||||
void CompactReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
|
||||
stream << "No test cases matched '" << unmatchedSpec << "'\n";
|
||||
}
|
||||
|
||||
void CompactReporter::assertionStarting( AssertionInfo const& ) {}
|
||||
|
@ -22,7 +22,7 @@ namespace Catch {
|
||||
|
||||
static std::string getDescription();
|
||||
|
||||
void noMatchingTestCases(std::string const& spec) override;
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override;
|
||||
|
||||
|
@ -381,11 +381,11 @@ std::string ConsoleReporter::getDescription() {
|
||||
return "Reports test results as plain lines of text";
|
||||
}
|
||||
|
||||
void ConsoleReporter::noMatchingTestCases(std::string const& spec) {
|
||||
stream << "No test cases matched '" << spec << "'\n";
|
||||
void ConsoleReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
|
||||
stream << "No test cases matched '" << unmatchedSpec << "'\n";
|
||||
}
|
||||
|
||||
void ConsoleReporter::reportInvalidArguments(std::string const& arg) {
|
||||
void ConsoleReporter::reportInvalidArguments( StringRef arg ) {
|
||||
stream << "Invalid Filter: " << arg << '\n';
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,8 @@ namespace Catch {
|
||||
~ConsoleReporter() override;
|
||||
static std::string getDescription();
|
||||
|
||||
void noMatchingTestCases(std::string const& spec) override;
|
||||
|
||||
void reportInvalidArguments(std::string const&arg) override;
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
void reportInvalidArguments( StringRef arg ) override;
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override;
|
||||
|
||||
|
@ -49,6 +49,11 @@ namespace Catch {
|
||||
stream( _config.stream() ) {}
|
||||
~CumulativeReporterBase() override;
|
||||
|
||||
|
||||
void noMatchingTestCases( StringRef ) override {}
|
||||
void reportInvalidArguments( StringRef ) override {}
|
||||
|
||||
|
||||
void testRunStarting( TestRunInfo const& ) override {}
|
||||
|
||||
void testCaseStarting( TestCaseInfo const& ) override {}
|
||||
|
@ -24,6 +24,8 @@ namespace Catch {
|
||||
EventListenerBase( ReporterConfig const& config ):
|
||||
IStreamingReporter( config.fullConfig() ) {}
|
||||
|
||||
void reportInvalidArguments( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting( AssertionInfo const& assertionInfo ) override;
|
||||
bool assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
|
||||
@ -32,7 +34,7 @@ namespace Catch {
|
||||
void listTests( std::vector<TestCaseHandle> const& tests ) override;
|
||||
void listTags( std::vector<TagInfo> const& tagInfos ) override;
|
||||
|
||||
void noMatchingTestCases( std::string const& spec ) override;
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
void testRunStarting( TestRunInfo const& testRunInfo ) override;
|
||||
void testCaseStarting( TestCaseInfo const& testInfo ) override;
|
||||
void testCasePartialStarting( TestCaseInfo const& testInfo,
|
||||
|
@ -64,14 +64,10 @@ namespace Catch {
|
||||
m_preferences.shouldReportAllAssertions = true;
|
||||
}
|
||||
|
||||
JunitReporter::~JunitReporter() {}
|
||||
|
||||
std::string JunitReporter::getDescription() {
|
||||
return "Reports test results in an XML format that looks like Ant's junitreport target";
|
||||
}
|
||||
|
||||
void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {}
|
||||
|
||||
void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) {
|
||||
CumulativeReporterBase::testRunStarting( runInfo );
|
||||
xml.startElement( "testsuites" );
|
||||
|
@ -19,12 +19,10 @@ namespace Catch {
|
||||
public:
|
||||
JunitReporter(ReporterConfig const& _config);
|
||||
|
||||
~JunitReporter() override;
|
||||
~JunitReporter() override = default;
|
||||
|
||||
static std::string getDescription();
|
||||
|
||||
void noMatchingTestCases(std::string const& /*spec*/) override;
|
||||
|
||||
void testRunStarting(TestRunInfo const& runInfo) override;
|
||||
|
||||
void testCaseStarting(TestCaseInfo const& testCaseInfo) override;
|
||||
|
@ -22,14 +22,14 @@ namespace Catch {
|
||||
m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;
|
||||
}
|
||||
|
||||
void ListeningReporter::noMatchingTestCases( std::string const& spec ) {
|
||||
void ListeningReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
|
||||
for ( auto& listener : m_listeners ) {
|
||||
listener->noMatchingTestCases( spec );
|
||||
listener->noMatchingTestCases( unmatchedSpec );
|
||||
}
|
||||
m_reporter->noMatchingTestCases( spec );
|
||||
m_reporter->noMatchingTestCases( unmatchedSpec );
|
||||
}
|
||||
|
||||
void ListeningReporter::reportInvalidArguments(std::string const&arg){
|
||||
void ListeningReporter::reportInvalidArguments( StringRef arg ) {
|
||||
for ( auto& listener : m_listeners ) {
|
||||
listener->reportInvalidArguments( arg );
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ namespace Catch {
|
||||
|
||||
public: // IStreamingReporter
|
||||
|
||||
void noMatchingTestCases( std::string const& spec ) override;
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
|
||||
void reportInvalidArguments(std::string const&arg) override;
|
||||
void reportInvalidArguments( StringRef arg ) override;
|
||||
|
||||
void benchmarkPreparing( StringRef name ) override;
|
||||
void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
SonarQubeReporter::~SonarQubeReporter() {}
|
||||
|
||||
void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) {
|
||||
CumulativeReporterBase::testRunStarting(testRunInfo);
|
||||
xml.startElement("testExecutions");
|
||||
|
@ -23,15 +23,13 @@ namespace Catch {
|
||||
m_preferences.shouldReportAllAssertions = true;
|
||||
}
|
||||
|
||||
~SonarQubeReporter() override;
|
||||
~SonarQubeReporter() override = default;
|
||||
|
||||
static std::string getDescription() {
|
||||
using namespace std::string_literals;
|
||||
return "Reports test results in the Generic Test Data SonarQube XML format"s;
|
||||
}
|
||||
|
||||
void noMatchingTestCases(std::string const& /*spec*/) override {}
|
||||
|
||||
void testRunStarting( TestRunInfo const& testRunInfo ) override;
|
||||
|
||||
void testRunEndedCumulative() override {
|
||||
|
@ -42,9 +42,8 @@ namespace Catch {
|
||||
|
||||
~StreamingReporterBase() override;
|
||||
|
||||
void noMatchingTestCases(std::string const&) override {}
|
||||
|
||||
void reportInvalidArguments(std::string const&) override {}
|
||||
void noMatchingTestCases( StringRef /*unmatchedSpec*/ ) override {}
|
||||
void reportInvalidArguments( StringRef /*invalidArgument*/ ) override {}
|
||||
|
||||
void testRunStarting( TestRunInfo const& _testRunInfo ) override;
|
||||
|
||||
|
@ -194,10 +194,8 @@ namespace Catch {
|
||||
|
||||
} // End anonymous namespace
|
||||
|
||||
TAPReporter::~TAPReporter() {}
|
||||
|
||||
void TAPReporter::noMatchingTestCases(std::string const& spec) {
|
||||
stream << "# No test cases matched '" << spec << "'\n";
|
||||
void TAPReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
|
||||
stream << "# No test cases matched '" << unmatchedSpec << "'\n";
|
||||
}
|
||||
|
||||
bool TAPReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||
|
@ -18,14 +18,14 @@ namespace Catch {
|
||||
StreamingReporterBase( config ) {
|
||||
m_preferences.shouldReportAllAssertions = true;
|
||||
}
|
||||
~TAPReporter() override;
|
||||
~TAPReporter() override = default;
|
||||
|
||||
static std::string getDescription() {
|
||||
using namespace std::string_literals;
|
||||
return "Reports test results in TAP format, suitable for test harnesses"s;
|
||||
}
|
||||
|
||||
void noMatchingTestCases(std::string const& spec) override;
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting( AssertionInfo const& ) override {}
|
||||
|
||||
|
@ -34,10 +34,6 @@ namespace Catch {
|
||||
return "Reports test results as TeamCity service messages"s;
|
||||
}
|
||||
|
||||
void skipTest( TestCaseInfo const& /* testInfo */ ) override {}
|
||||
|
||||
void noMatchingTestCases( std::string const& /* spec */ ) override {}
|
||||
|
||||
void testRunStarting( TestRunInfo const& groupInfo ) override;
|
||||
void testRunEnded( TestRunStats const& testGroupStats ) override;
|
||||
|
||||
|
@ -46,10 +46,6 @@ namespace Catch {
|
||||
.writeAttribute( "line"_sr, sourceInfo.line );
|
||||
}
|
||||
|
||||
void XmlReporter::noMatchingTestCases( std::string const& s ) {
|
||||
StreamingReporterBase::noMatchingTestCases( s );
|
||||
}
|
||||
|
||||
void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) {
|
||||
StreamingReporterBase::testRunStarting( testInfo );
|
||||
std::string stylesheetRef = getStylesheetRef();
|
||||
|
@ -29,8 +29,6 @@ namespace Catch {
|
||||
|
||||
public: // StreamingReporterBase
|
||||
|
||||
void noMatchingTestCases(std::string const& s) override;
|
||||
|
||||
void testRunStarting(TestRunInfo const& testInfo) override;
|
||||
|
||||
void testCaseStarting(TestCaseInfo const& testInfo) override;
|
||||
|
Loading…
Reference in New Issue
Block a user