We have a setup where we use Jenkins, Clover, clover-ant and the jenkins-clover plugin to measure our codecoverage. We see that all unittest run with PowerMockito aren't taken into account in the clover report (codecoverage - 0%).
When when we run the unittest inside Eclipse with the eclipse-clover plugin the results are taken into account.
Any suggestion where to look for a solution?
I am also facing same issue. We have configured clover in bamboo for ant project. Only for powermockito classes we are getting coverage as 0%. What was the solution for this issue?
I will create an example project with all the problem, however due to other activities it might take a few week. thx for the replies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
May I ask you to create a ticket at https://support.atlassian.comin the "Clover Support" project and attach: build.xml, build log, small code sample? I'd like to investigate it furhter. We can later go back to this forum and post an answer as soon as I'll figure it out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marek Parfianowicz I am also facing same issue. We have configured clover in bamboo for ant project. Only for powermockito classes we are getting coverage as 0%. What was the solution for this issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is our test target
<target name="tst.run" depends="services.tst.build, rest.tst.build">
<junit fork="false" forkmode="perTest" printsummary="yes" maxmemory="1024m" >
<jvmarg value="-Dfile.encoding=UTF-8"/>
<classpath>
<path refid="application.classpath" />
<path refid="eclipselink.libraryclasspath" />
<path refid="unittest.libraryclasspath"/>
<pathelement location="${build.services}"/>
<pathelement location="${build.web}"/>
<pathelement location="${clover.classpath}"/>
</classpath>
<formatter type="xml" />
<batchtest todir="${junit.xml.dir}" >
<fileset dir="${src.services.tst}">
<include name="**/*Test.java"/>
</fileset>
<fileset dir="${src.rest.tst}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
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.
I've done some additional testing with the flush policy. All three options (threaded, directed and interval) give the same results (coverage = 0%). Also completely removing the workspace to start clean didn't do anything.....
We are not testing against a server, so that shouldn't be an issue.
Belowe I've added the clover-setup we use in our ANT build script:
<target name="with.clover"> <taskdef resource="cloverlib.xml" classpath="${clover.classpath}"/> <property name="test.target" value="tst.run" /> <property name="clover.dest" value="${build.dir}/clover" /> <clover-env/> <clover-setup initstring="${build.dir}/clover-db/coverage.db" tmpdir="${build.Clover}" flushpolicy="directed"> <files> <exclude name="**/generatedclassespackage1/**.java" /> <exclude name="**/generatedclassespackage2/**/*.java"/> </files> </clover-setup> </target>
And the ant targets we run are "clean init with.clover build tst.run clover.report"
Hopefully this gives some new insight.... next up: make simple project to reproduce.... or investigate migrating to maven ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
More details about the coverage database and recording files:
and about the flush policy:
and how to deal with coverage of applications running on app servers:
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.
In the build logging I see that te code is intrumented before the tests are run:
Below is an anonymous output.
clover: [clover-env] Loading clover.xml: jar:file:/<pathto>clover.xml Trying to override old definition of task clover-env [clover-setup] Clover Version 3.2.1, built on January 10 2014 (build-914) [clover-setup] Loaded from: <pathto>\clover-ant-3.2.1\lib\clover.jar [clover-setup] Clover: <licence details> [clover-setup] Clover is enabled with initstring '<pathto>clover-db/coverage.db' services.build: [mkdir] Created dir: <pathto>\services [javac] Compiling X source files to <pathto> [clover] Clover Version 3.2.1, built on January 10 2014 (build-914) [clover] Loaded from: <pathto>\lib\clover.jar [clover] Clover: <licence details> [clover] Updating existing database at '<pathto>clover-db\coverage.db'. [clover] Processing files at 1.7 source level. [clover] Clover all over. Instrumented X files (14 packages). [clover] Elapsed time = 0.78 secs. (X files/sec, X srclines/sec) [jar] Building jar: <pathto>library.jar tst.run: [junit] Running nl.sidn.<pathtotestclass> [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.11 sec
In the Clover coverage repport I can see that the code has no coverage, but that it's hit once in a test that is passed succesful... and that is confusing me... I've attached a detailed image.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are using clover-setup. But your remark concerning the order of calling is interesting, I will have to look into that...
It seems logical that this is the problem, I will look into it and come back here with the answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are using clover-setup. But your remark concerning the order of calling is interesting, I will have to look into that...
It seems logical that this is the problem, I will look into it and come back here with the answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's worth to check whether the PowerMockito takes sources instrumented by Clover or the original ones. Please note that the Clover performs source code instrumentation so it should be called before PowerMockito, which works on the bytecode level.
Could share snippets of your build.xml with PowerMockito and Clover configuration and the order in which they're called?
Are you using <clover-setup> or <clover-instr>?
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.