We have a separate project for source and test. Also, the source files lie directly under src/ instead of src/main/java. The clover shows 0 coverage for these projects. Is there any setup we can do to make clover produce a correct coverage?
Thanks a lot guys to locate the issue. I followed the steps specified in the link and facing some issues:
On executing mvn -X clover2:instrument -DcloverOutputDirectory=../proj_instr, I am getting error
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.16.0:package-feature (default-package-feature) on project com.abc.labs.proj.scan.feature: Execution default-package-feature of goal org.eclipse.tycho:tycho-packaging-plugin:0.16.0:package-feature failed: com.abc.sys:com.abc.labs.proj.scan:eclipse-plugin:2.3.0-SNAPSHOT does not provide an artifact with classifier 'null' -> [Help 1]
I am not able to understand this error. Is this error due to some missing configuration in project or tycho or clover?
You can't use Clover with Tycho plugin in a standard way. The problem is that Tycho plugin ignores Maven's source roots. More details here:
https://confluence.atlassian.com/display/CLOVER/Using+Clover+with+Maven+Tycho+Plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
proj-app contains all the modules, under which proj-parent and project-test-parent act as parents to all other projects.
proj-app - proj-parent (parent to all non-.tests projects) (has a tycho atrifact as a parent) - proj-test-parent (parent to all .tests projects) (has proj-parent as parent)
Clover is configured in proj-parent.
The metric for the project com.abc.labs.proj.rules.tests is
<metrics conditionals="26" methods="13" classes="1" files="1" packages="1" coveredstatements="0" complexity="26" loc="314" ncloc="255" coveredmethods="0" coveredconditionals="0" statements="128" coveredelements="0" elements="167"/>
The metric for the 6 packages are:
<metrics classes="1" methods="13" conditionals="26" files="1" ncloc="255" coveredstatements="0" coveredmethods="0" complexity="26" coveredconditionals="0" statements="128" loc="314" coveredelements="0" elements="167"/> <metrics classes="38" methods="102" conditionals="6" files="38" ncloc="1562" coveredstatements="0" coveredmethods="0" complexity="105" coveredconditionals="0" statements="711" loc="2009" coveredelements="0" elements="819"/> <metrics classes="1" methods="6" conditionals="6" files="1" ncloc="85" coveredstatements="0" coveredmethods="0" complexity="10" coveredconditionals="0" statements="47" loc="114" coveredelements="0" elements="59"/> <metrics classes="1" methods="3" conditionals="0" files="1" ncloc="39" coveredstatements="0" coveredmethods="0" complexity="3" coveredconditionals="0" statements="12" loc="48" coveredelements="0" elements="15"/> <metrics classes="4" methods="24" conditionals="56" files="3" ncloc="452" coveredstatements="0" coveredmethods="0" complexity="60" coveredconditionals="0" statements="225" loc="635" coveredelements="0" elements="305"/> <metrics classes="1" methods="19" conditionals="0" files="1" ncloc="190" coveredstatements="0" coveredmethods="0" complexity="19" coveredconditionals="0" statements="128" loc="250" coveredelements="0" elements="147"/> <metrics classes="3" methods="5" conditionals="0" files="3" ncloc="157" coveredstatements="0" coveredmethods="0" complexity="5" coveredconditionals="0" statements="107" loc="211" coveredelements="0" elements="112"/>
The first two metrics are for the same package but shown twice by clover. That package in all has 39 files. There seems to be an issue since the project metric here shows packages=1 while it actually has 6.
The metric for the project com.abc.labs.proj.rules is
<metrics conditionals="1222" methods="771" classes="149" files="133" packages="20" coveredstatements="0" complexity="1425" loc="8621" ncloc="6734" coveredmethods="0" coveredconditionals="0" statements="2890" coveredelements="0" elements="4883"/>
There exists a file named clover.db in D:\GitHub\repos\proj-app\com.abc.labs.proj.rules\target\clover
There exists a file named clover.db in D:\GitHub\repos\proj-app\com.abc.labs.proj.rules.test\target\clover
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I've looked at the logs. And it seems that sources for both com.abc.labs.proj.rules and com.abc.labs.proj.rules.tests modules are getting instrumented by Clover:
[INFO] ------------------------------------------------------------------------ [INFO] Building com.abc.labs.proj.rules 2.3.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ com.abc.labs.proj.rules --- [INFO] Deleting D:\GitHub\repos\proj-app\com.abc.labs.proj.rules\target ... [INFO] Creating new database at 'D:\GitHub\repos\proj-app\com.abc.labs.proj.rules\target\clover\clover.db'. [INFO] Processing files at 1.7 source level. [INFO] Clover all over. Instrumented 133 files (20 packages). [INFO] Elapsed time = 3.593 secs. (37.016 files/sec, 2,399.388 srclines/sec) ... [INFO] Building com.abc.labs.proj.rules.tests 2.3.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ ... [INFO] Creating new database at 'D:\GitHub\repos\proj-app\com.abc.labs.proj.rules.tests\target\clover\clover.db'. [INFO] Processing files at 1.7 source level. [INFO] Clover all over. Instrumented 48 files (6 packages). [INFO] 97 test methods detected. [INFO] Elapsed time = 1.491 secs. (32.193 files/sec, 2,401.744 srclines/sec)
I have couple of additional questions for you
D:\GitHub\repos\proj-app\com.abc.labs.proj.rules.tests\target\site\clover\clover.xml
file shows 0% coverage?D:\GitHub\repos\proj-app\com.abc.labs.proj.rules\target\site\clover/clover.xml
file shows 0% coverage?D:\GitHub\repos\proj-app\com.abc.labs.proj.rules\target\clover
directory?D:\GitHub\repos\proj-app\com.abc.labs.proj.rules.test\target\clover
directory?-X
switch in order to get more detailed logs and attach the output?
Best regards
Grzegorz Lewandowski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please tell what Maven command did you run? If you see your classes in the HTML report then it means that code was successfully instrumented by Clover. Having no 0% coverage means that no coverage recording files were produced (or found).
Possible causes:
... but I would have to see build logs to tell what went wrong.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, so I did that but clover still shows me 0 code coverage for those projects. Is there any requirement to keep both source and test files under the same project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use build-helper-maven-plugin:add-source/add-test-source to specify app/test source folders. Note that these goals shall be called before calling the clover2:setup goal. You can achieve this by binding them to different build phases in your pom.xml.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.