[JAVA-493] Enable test coverage tool Created: 16/Dec/11  Updated: 26/Nov/12  Resolved: 11/Nov/12

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

To improve test coverage, it would be helpful to have the option to run unit tests with a test coverage tool.



 Comments   
Comment by auto [ 10/Sep/12 ]

Author:

{u'date': u'2012-09-10T10:48:31-07:00', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: Merge pull request #80 from trnl/master

JAVA-493: Enable test coverage tool and clean up Ant targets
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/d95e6f82411b09c8cdfd9ec4eb319b78f78a7550

Comment by Uladzimir Mihura [ 07/Sep/12 ]

Fixed here:

https://github.com/mongodb/mongo-java-driver/pull/80

-vova

Comment by Jeffrey Yemin [ 22/Mar/12 ]

I found some work I had done on this. Feel free to use it:

+    <property name="cobertura.dir" value="${env.COBERTURA_HOME}/cobertura-1.9.4.1" />
+
+    <path id="cobertura.classpath">
+        <fileset dir="${cobertura.dir}">
+            <include name="cobertura.jar" />
+            <include name="lib/**/*.jar" />
+        </fileset>
+    </path>
+
+    <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
+
     <!-- ******************************************************************* -->
     <!-- The init target.                                                    -->
     <!-- ******************************************************************* -->
@@ -351,6 +362,24 @@ limitations under the License.
         <!--</clover-report>-->
     </target>
 
+    <target name="jenkins-test-cobertura" depends="compile">
+
+        <cobertura-instrument todir="build/instrumented-main">
+            <fileset dir="build/main">
+                <include name="**/*.class"/>
+            </fileset>
+        </cobertura-instrument>
+
+        <testng outputdir="${testdir}" listeners="com.mongodb.util.TestNGListener" haltonfailure="false" verbose="1">
+            <classpath location="build/instrumented"/>
+            <classpath location="build/main"/>
+            <classpath location="build/test"/>
+            <jvmarg value="-Xmx512M" />
+            <xmlfileset dir="." includes="testng.xml"/>
+        </testng>
+        <cobertura-report format="xml" srcdir="src/main" destdir="/build/coberture-reportfcomp"/>
+    </target>

Comment by Jeffrey Yemin [ 11/Mar/12 ]

Let's go with Cobertura. It works fine with Jenkins, and it's free.

Generated at Thu Feb 08 08:52:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.