Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:05:36

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 = true;
0025             m_shouldStoreSuccesfulAssertions = false;
0026         }
0027 
0028         ~SonarQubeReporter() override = default;
0029 
0030         static std::string getDescription() {
0031             using namespace std::string_literals;
0032             return "Reports test results in the Generic Test Data SonarQube XML format"s;
0033         }
0034 
0035         void testRunStarting( TestRunInfo const& testRunInfo ) override;
0036 
0037         void testRunEndedCumulative() override {
0038             writeRun( *m_testRun );
0039             xml.endElement();
0040         }
0041 
0042         void writeRun( TestRunNode const& groupNode );
0043 
0044         void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes);
0045 
0046         void writeTestCase(TestCaseNode const& testCaseNode);
0047 
0048         void writeSection(std::string const& rootName, SectionNode const& sectionNode, bool okToFail);
0049 
0050         void writeAssertions(SectionNode const& sectionNode, bool okToFail);
0051 
0052         void writeAssertion(AssertionStats const& stats, bool okToFail);
0053 
0054     private:
0055         XmlWriter xml;
0056     };
0057 
0058 
0059 } // end namespace Catch
0060 
0061 #endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED