Skip to content

Code coverage isn't correct #16

@wspr

Description

@wspr

Maybe @ranford can help me here :)

For one test

I've added a choice = 3; option in runtestsuite.m which runs the test suite on ONLY testcuboidtorque03.m and produces coverage-debug.xml. Comparing the output here for private/cuboid_torque_z_z.m, there are lines in the coverage XML like:

              <line hits="384" number="82"/>
              <line hits="4" number="84"/>
              <line hits="4" number="85"/>
              <line hits="4" number="86"/>
              <line hits="384" number="89"/>
              <line hits="4" number="90"/>
              <line hits="4" number="91"/>
              ...

which match up with the edge case calculations:

        if any(a)
          Ex(a) = 1/8*w(a).*(-w2(a)-2*Cw.*w(a)-8*Cv.*abs(w(a))+w(a).*(2*Cw+w(a)).*log(w2(a)));
          Ey(a) = 1/8*w(a).*(+w2(a)+2*Cw.*w(a)+8*Cu.*abs(w(a))-w(a).*(2*Cw+w(a)).*log(w2(a)));
          Ez(a) = 1/4*(Cu-Cv)*w2(a).*log(w2(a));
        end

These are explicitly tested in this test, hence the 4 hits on such lines.

For all tests

But if I change to choice=2; in runtestsuite.m the test suite runs on all tests, and produce coverage.xml — this is the file that is linked to CodeCov. After running all tests I receive:

              <line hits="192" number="82"/>
              <line hits="0" number="84"/>
              <line hits="0" number="85"/>
              <line hits="0" number="86"/>
              <line hits="192" number="89"/>
              <line hits="0" number="90"/>
              <line hits="0" number="91"/>

Clearly something is going wrong here; shouldn't the hits per line accumulate as the entire test suite is run? More importantly, my coverage for this file is less than it should be!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions