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

Support for CoverageUnit METHOD #698

Open
sLite opened this issue Oct 31, 2024 · 2 comments
Open

Support for CoverageUnit METHOD #698

sLite opened this issue Oct 31, 2024 · 2 comments
Assignees
Labels
Feature Feature request issue type S: postponed Status: work on the issue is not in the short term plans

Comments

@sLite
Copy link

sLite commented Oct 31, 2024

It would be nice to be able to verify the method % coverage shown in the report.

We currently verify on 90% instructions per class, but we always want to cover 100% of the methods, which is currently not possible as far as i understand the documentation regarding verification rules.

@sLite sLite added Feature Feature request issue type S: untriaged Status: issue reported but unprocessed labels Oct 31, 2024
@shanshin shanshin added S: postponed Status: work on the issue is not in the short term plans and removed S: untriaged Status: issue reported but unprocessed labels Nov 4, 2024
@egor-bogomolov
Copy link

Hi! Are there any known workarounds on how to extract the method-level coverage info from the reports?

@shanshin
Copy link
Collaborator

@egor-bogomolov, hi
You can generate an XML report, parse it and count the methods that are not covered.

the XML path to the method report/package/class/method

e.g.

<report name="debug">
  <package name="com/example">
    <class name="com/example/Foo">
      <method name="&lt;init&gt;" desc="()V" line="8">
        <counter type="INSTRUCTION" missed="3" covered="0"/> 
        <counter type="LINE" missed="1" covered="0"/>
        <counter type="COMPLEXITY" missed="1" covered="0"/>
        <counter type="METHOD" missed="1" covered="0"/>
      </method>
      <method name="exists" desc="()Ljava/lang/Boolean;" line="11">
        <counter type="INSTRUCTION" missed="1" covered="10"/>
        <counter type="BRANCH" missed="1" covered="1"/>
        <counter type="LINE" missed="1" covered="3"/>
        <counter type="COMPLEXITY" missed="1" covered="1"/>
        <counter type="METHOD" missed="0" covered="1"/>
      </method>
      <method name="delete" desc="()V" line="11">
        <counter type="INSTRUCTION" missed="0" covered="15"/>
        <counter type="BRANCH" missed="0" covered="1"/>
        <counter type="LINE" missed="0" covered="3"/>
        <counter type="COMPLEXITY" missed="1" covered="1"/>
        <counter type="METHOD" missed="0" covered="1"/>
      </method>
    </class>
  </package>

Depending on which coverage metric you choose, you can count in different ways: for example, if all rows in the method are not covered ( covered="0" for type="LINE" ), then consider this method uncovered, otherwise consider it covered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request issue type S: postponed Status: work on the issue is not in the short term plans
Projects
None yet
Development

No branches or pull requests

3 participants