Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cobertura coverage array #206

Merged
merged 2 commits into from
Jul 26, 2017
Merged

Fix Cobertura coverage array #206

merged 2 commits into from
Jul 26, 2017

Conversation

ale7714
Copy link
Contributor

@ale7714 ale7714 commented Jul 26, 2017

Cobertura formatter is currently working under the assumption that the coverage tool is gonna report lines ordered by number and without duplicate line numbers. This causes that for coverage data that looks like this:

<package name="" line-rate="1.0" branch-rate="1.0" complexity="1.0">
  <classes>
    <class name="Main" filename="Main.java" line-rate="1.0" branch-rate="1.0" complexity="1.0">
      <lines>
        <line number="4" hits="8" branch="false" />
        <line number="2" hits="4" branch="false" />
        <line number="4" hits="1" branch="false" />
        <line number="1" hits="6" branch="false" />
      </lines>
    </class>
  </classes>
</package>

We're going to incorrectly report a coverage array of [0, 0, 0, 8, 4,1,6]. And we should report [6, 4, nil,9]

This PR addresses this issues by:

  • Sorting lines by number before building the coverage array
  • For lines with the same number, we're going to sum the hits

Copy link
Contributor

@maxjacobson maxjacobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Just wondering, does the test reporter support go yet? If so, we should hook it up :)

Copy link

@ABaldwinHunter ABaldwinHunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix

@ale7714
Copy link
Contributor Author

ale7714 commented Jul 26, 2017

@maxjacobson yes and yes! We should make sometime to do this :)

@ale7714 ale7714 merged commit 0f155be into master Jul 26, 2017
@ale7714 ale7714 deleted the ap-fix-cobertura branch July 26, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants