Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-6790

Coverage summaries display wrong values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Component/s: cobertura-plugin
    • Labels:
      None
    • Environment:
      Hudson 1.362, cobertura-maven-plugin 2.4, cobertura hudson plugin 0.8.11
    • Similar Issues:

      Description

      Within my source code I have no conditionals (see code below). In view 'Cobertura Coverage Report -> Package Breakdown --> Bean.java', column 'Conditionals' says 'N/A'. But in views 'Project Coverage Summary' and 'Package Coverage Summary' Cobertura reports 'Conditionals 0% 0/0' and my project gets cloudy :/ This is not a proper behavior from my point of view what do you think?

      br
      vollecker
      ----------------------------------------
      public class Bean {
      public void noConditionals()

      { //do nothing }


      }
      ----------------------------------------
      public class Tester extends TestCase {
      public void testBean()

      { Bean bean = new Bean(); bean.noConditionals(); }

      }
      ----------------------------------------

        Attachments

          Activity

          Hide
          jan_ruzicka jan_ruzicka added a comment -

          The cobertura reports generated by maven havdle this case gracefully by showing N/A for the totals.

          I think the issue may be in the hudson.plugins.cobertura.Ratio as it returns 0 for case 0/0.
          It should be 100% because all conditionals are covered.
          This is a special case.

          public float getPercentageFloat()

          { return denominator == 0 ? 0 : (100 * numerator / denominator); }

          may be better as

          public float getPercentageFloat()

          { return denominator == 0 ? (numerator == 0 ? 100 : 0) : (100 * numerator / denominator); }
          Show
          jan_ruzicka jan_ruzicka added a comment - The cobertura reports generated by maven havdle this case gracefully by showing N/A for the totals. I think the issue may be in the hudson.plugins.cobertura.Ratio as it returns 0 for case 0/0. It should be 100% because all conditionals are covered. This is a special case. public float getPercentageFloat() { return denominator == 0 ? 0 : (100 * numerator / denominator); } may be better as public float getPercentageFloat() { return denominator == 0 ? (numerator == 0 ? 100 : 0) : (100 * numerator / denominator); }
          Hide
          mindless Alan Harder added a comment -

          why the numerator==0 check? if denominator is 0 then I'd expect numerator has to be zero, right? so seems like we could just change "0" to "100" there, no?

          Show
          mindless Alan Harder added a comment - why the numerator==0 check? if denominator is 0 then I'd expect numerator has to be zero, right? so seems like we could just change "0" to "100" there, no?
          Hide
          jan_ruzicka jan_ruzicka added a comment -

          When it is x/0 for x non zero it means to me that the metrics are broken because there is some unexpected coverage.

          I see it as 0% - bad; 100% - good.

          Show
          jan_ruzicka jan_ruzicka added a comment - When it is x/0 for x non zero it means to me that the metrics are broken because there is some unexpected coverage. I see it as 0% - bad; 100% - good.
          Hide
          mindless Alan Harder added a comment -

          ok, please go ahead and commit the change. add a comment that we don't expect numerator>0 if denominator==0 but this is a "just in case".

          Show
          mindless Alan Harder added a comment - ok, please go ahead and commit the change. add a comment that we don't expect numerator>0 if denominator==0 but this is a "just in case".
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : jan_ruzicka
          Path:
          trunk/hudson/plugins/cobertura/src/main/java/hudson/plugins/cobertura/Ratio.java
          http://jenkins-ci.org/commit/33426
          Log:
          [FIXED JENKINS-6790] Coverage summaries display wrong values - a quick fix

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : jan_ruzicka Path: trunk/hudson/plugins/cobertura/src/main/java/hudson/plugins/cobertura/Ratio.java http://jenkins-ci.org/commit/33426 Log: [FIXED JENKINS-6790] Coverage summaries display wrong values - a quick fix
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : jan_ruzicka
          Path:
          trunk/hudson/plugins/cobertura/src/main/java/hudson/plugins/cobertura/Ratio.java
          http://jenkins-ci.org/commit/33427
          Log:
          JENKINS-6790 Coverage summaries display wrong values - correction of numerical type

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : jan_ruzicka Path: trunk/hudson/plugins/cobertura/src/main/java/hudson/plugins/cobertura/Ratio.java http://jenkins-ci.org/commit/33427 Log: JENKINS-6790 Coverage summaries display wrong values - correction of numerical type

            People

            • Assignee:
              jan_ruzicka jan_ruzicka
              Reporter:
              vollecker vollecker
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: