MOxUnit / MOcov

A coverage report generator for Matlab and GNU Octave.
20 stars 12 forks source link

Coverage fails with Octave classes #24

Open TimurDela opened 2 years ago

TimurDela commented 2 years ago

When I test Octave functions, the coverage report works well. but if I test classes (both with the old '@' syntax or the newer classdef) the tests run successfully but the report is empty:

<classes>
<class name="polynomial" filename="myClasses/polynomial.m" line-rate="1.000" branch-rate="0.0">
<methods></methods><lines>
</lines>
</class>
<class name="square" filename="myFunctions/square.m" line-rate="1.000" branch-rate="0.0">
<methods></methods><lines>
<line number="2" hits="1" branch="false"/>
</lines>
</class>

It is also a bit weird that myFunctions/square.m has method tags since it is not a class but OK.

Or am I doing something wrong? It would be nice to include a working example in the repo.

nno commented 2 years ago

Greetings,

apologies for the late reaction, I am only seeing this issue now.

I don't think you are doing anything wrong. mocov uses a rudimentary parser to determine which lines are executable. In the current implementation, anything in a classdef is not considered executable. For details, see @MOcovMFile/MOcovMFile, method get_mfile_props. If this issue still affects you, I may look into this and see if the parser can be made a bit smarter; but currently it does not have top priority from my side. A Pull Request would always be appreciated though.

jorgepz commented 5 months ago

Hi @TimurDela I am adding a minimal class example in a test repo to try this out. It seems to be working for an '@' class. The report is generated and uploaded to codecov

jorgepz commented 3 months ago

We can add a test in this repo to verify it is working