Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:52:14

0001 
0002 //              Copyright Catch2 Authors
0003 // Distributed under the Boost Software License, Version 1.0.
0004 //   (See accompanying file LICENSE.txt or copy at
0005 //        https://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // SPDX-License-Identifier: BSL-1.0
0008 #ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
0009 #define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
0010 
0011 #include <catch2/reporters/catch_reporter_cumulative_base.hpp>
0012 
0013 #include <catch2/internal/catch_xmlwriter.hpp>
0014 #include <catch2/internal/catch_move_and_forward.hpp>
0015 
0016 namespace Catch {
0017 
0018     class SonarQubeReporter final : public CumulativeReporterBase {
0019     public:
0020         SonarQubeReporter(ReporterConfig&& config)
0021         : CumulativeReporterBase(CATCH_MOVE(config))
0022         , xml(m_stream) {
0023             m_preferences.shouldRedirectStdOut = true;
0024             m_preferences.shouldReportAllAssertions = false;
0025             m_shouldStoreSuccesfulAssertions = false;
0026         }
0027 
0028         static std::string getDescription() {
0029             using namespace std::string_literals;
0030             return "Reports test results in the Generic Test Data SonarQube XML format"s;
0031         }
0032 
0033         void testRunStarting( TestRunInfo const& testRunInfo ) override;
0034 
0035         void testRunEndedCumulative() override {
0036             writeRun( *m_testRun );
0037             xml.endElement();
0038         }
0039 
0040         void writeRun( TestRunNode const& runNode );
0041 
0042         void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes);
0043 
0044         void writeTestCase(TestCaseNode const& testCaseNode);
0045 
0046         void writeSection(std::string const& rootName, SectionNode const& sectionNode, bool okToFail);
0047 
0048         void writeAssertions(SectionNode const& sectionNode, bool okToFail);
0049 
0050         void writeAssertion(AssertionStats const& stats, bool okToFail);
0051 
0052     private:
0053         XmlWriter xml;
0054     };
0055 
0056 
0057 } // end namespace Catch
0058 
0059 #endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED