cobertura-coverage.xml format not supported by SonarQube for unit tests written in javascript





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















  • Using istanbul and cobertura, I have managed to get a coverage report
    for my unit test case written in Javascript(Node js) in XML
    format(cobertura-coverage.xml). But the created xml does not support
    the format required by SonarQube.

  • I went through many solutions on Stackoverflow but couldn't find one
    matching my criteria.


Following is the content generated in the cobertura-coverage.xml file -



<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage lines-valid="5" lines-covered="5" line-rate="1" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1542872388848" complexity="0" version="0.1">
<sources>
<source>/home/sreenesh/Sreenesh/Other_Projects/test/tests</source>
</sources>
<packages>
<package name="tests" line-rate="1" branch-rate="1" >
<classes>
<class name="test1.js" filename="test1.js" line-rate="1" branch-rate="1" >
<methods>
<method name="(anonymous_1)" hits="1" signature="()V" >
<lines><line number="4" hits="1" /></lines>
</method>
</methods>
<lines>
<line number="1" hits="1" branch="false" />
<line number="2" hits="1" branch="false" />
<line number="4" hits="1" branch="false" />
<line number="5" hits="1" branch="false" />
<line number="6" hits="1" branch="false" />
</lines>
</class>
</classes>
</package>





In above xml, version for coverage generated is '0.1' and this format is not matching for importing it for Coverage in SonarQube.



Sonar analysis is showing following error -



ERROR: Error during SonarQube Scanner execution
ERROR: Error during parsing of the generic coverage report '/home/sreenesh/Sreenesh/Other_Projects/test/tests/cobertura-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Unknown XML node, expected "file" but got "sources" at line 4


Please help me with correct steps to generate xml matching the format here. Thanks.










share|improve this question





























    0
















    • Using istanbul and cobertura, I have managed to get a coverage report
      for my unit test case written in Javascript(Node js) in XML
      format(cobertura-coverage.xml). But the created xml does not support
      the format required by SonarQube.

    • I went through many solutions on Stackoverflow but couldn't find one
      matching my criteria.


    Following is the content generated in the cobertura-coverage.xml file -



    <?xml version="1.0" ?>
    <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
    <coverage lines-valid="5" lines-covered="5" line-rate="1" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1542872388848" complexity="0" version="0.1">
    <sources>
    <source>/home/sreenesh/Sreenesh/Other_Projects/test/tests</source>
    </sources>
    <packages>
    <package name="tests" line-rate="1" branch-rate="1" >
    <classes>
    <class name="test1.js" filename="test1.js" line-rate="1" branch-rate="1" >
    <methods>
    <method name="(anonymous_1)" hits="1" signature="()V" >
    <lines><line number="4" hits="1" /></lines>
    </method>
    </methods>
    <lines>
    <line number="1" hits="1" branch="false" />
    <line number="2" hits="1" branch="false" />
    <line number="4" hits="1" branch="false" />
    <line number="5" hits="1" branch="false" />
    <line number="6" hits="1" branch="false" />
    </lines>
    </class>
    </classes>
    </package>





    In above xml, version for coverage generated is '0.1' and this format is not matching for importing it for Coverage in SonarQube.



    Sonar analysis is showing following error -



    ERROR: Error during SonarQube Scanner execution
    ERROR: Error during parsing of the generic coverage report '/home/sreenesh/Sreenesh/Other_Projects/test/tests/cobertura-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
    ERROR: Caused by: Unknown XML node, expected "file" but got "sources" at line 4


    Please help me with correct steps to generate xml matching the format here. Thanks.










    share|improve this question

























      0












      0








      0









      • Using istanbul and cobertura, I have managed to get a coverage report
        for my unit test case written in Javascript(Node js) in XML
        format(cobertura-coverage.xml). But the created xml does not support
        the format required by SonarQube.

      • I went through many solutions on Stackoverflow but couldn't find one
        matching my criteria.


      Following is the content generated in the cobertura-coverage.xml file -



      <?xml version="1.0" ?>
      <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
      <coverage lines-valid="5" lines-covered="5" line-rate="1" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1542872388848" complexity="0" version="0.1">
      <sources>
      <source>/home/sreenesh/Sreenesh/Other_Projects/test/tests</source>
      </sources>
      <packages>
      <package name="tests" line-rate="1" branch-rate="1" >
      <classes>
      <class name="test1.js" filename="test1.js" line-rate="1" branch-rate="1" >
      <methods>
      <method name="(anonymous_1)" hits="1" signature="()V" >
      <lines><line number="4" hits="1" /></lines>
      </method>
      </methods>
      <lines>
      <line number="1" hits="1" branch="false" />
      <line number="2" hits="1" branch="false" />
      <line number="4" hits="1" branch="false" />
      <line number="5" hits="1" branch="false" />
      <line number="6" hits="1" branch="false" />
      </lines>
      </class>
      </classes>
      </package>





      In above xml, version for coverage generated is '0.1' and this format is not matching for importing it for Coverage in SonarQube.



      Sonar analysis is showing following error -



      ERROR: Error during SonarQube Scanner execution
      ERROR: Error during parsing of the generic coverage report '/home/sreenesh/Sreenesh/Other_Projects/test/tests/cobertura-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
      ERROR: Caused by: Unknown XML node, expected "file" but got "sources" at line 4


      Please help me with correct steps to generate xml matching the format here. Thanks.










      share|improve this question















      • Using istanbul and cobertura, I have managed to get a coverage report
        for my unit test case written in Javascript(Node js) in XML
        format(cobertura-coverage.xml). But the created xml does not support
        the format required by SonarQube.

      • I went through many solutions on Stackoverflow but couldn't find one
        matching my criteria.


      Following is the content generated in the cobertura-coverage.xml file -



      <?xml version="1.0" ?>
      <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
      <coverage lines-valid="5" lines-covered="5" line-rate="1" branches-valid="0" branches-covered="0" branch-rate="1" timestamp="1542872388848" complexity="0" version="0.1">
      <sources>
      <source>/home/sreenesh/Sreenesh/Other_Projects/test/tests</source>
      </sources>
      <packages>
      <package name="tests" line-rate="1" branch-rate="1" >
      <classes>
      <class name="test1.js" filename="test1.js" line-rate="1" branch-rate="1" >
      <methods>
      <method name="(anonymous_1)" hits="1" signature="()V" >
      <lines><line number="4" hits="1" /></lines>
      </method>
      </methods>
      <lines>
      <line number="1" hits="1" branch="false" />
      <line number="2" hits="1" branch="false" />
      <line number="4" hits="1" branch="false" />
      <line number="5" hits="1" branch="false" />
      <line number="6" hits="1" branch="false" />
      </lines>
      </class>
      </classes>
      </package>





      In above xml, version for coverage generated is '0.1' and this format is not matching for importing it for Coverage in SonarQube.



      Sonar analysis is showing following error -



      ERROR: Error during SonarQube Scanner execution
      ERROR: Error during parsing of the generic coverage report '/home/sreenesh/Sreenesh/Other_Projects/test/tests/cobertura-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
      ERROR: Caused by: Unknown XML node, expected "file" but got "sources" at line 4


      Please help me with correct steps to generate xml matching the format here. Thanks.







      javascript sonarqube code-coverage cobertura istanbul






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 10:26









      Sreenesh KiniSreenesh Kini

      11




      11
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428834%2fcobertura-coverage-xml-format-not-supported-by-sonarqube-for-unit-tests-written%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428834%2fcobertura-coverage-xml-format-not-supported-by-sonarqube-for-unit-tests-written%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?