summaryrefslogtreecommitdiffstats
path: root/Tests/CoberturaCoverage
diff options
context:
space:
mode:
authorJoseph Snyder <joe.snyder@kitware.com>2014-05-29 17:47:31 (GMT)
committerJoseph Snyder <joe.snyder@kitware.com>2014-06-04 14:26:19 (GMT)
commit50daf239b001ddda61449044e75bb98651e99d21 (patch)
treece47d4d773037e2515149de475c7edeee6baff17 /Tests/CoberturaCoverage
parenta2822d30899f3fc2ad96abfdf5de0d0ce4166139 (diff)
downloadCMake-50daf239b001ddda61449044e75bb98651e99d21.zip
CMake-50daf239b001ddda61449044e75bb98651e99d21.tar.gz
CMake-50daf239b001ddda61449044e75bb98651e99d21.tar.bz2
CTest: Generalize Cobertura coverage format handling
Add support for Cobertura coverage files written by Java. Add a test which uses the report from a Java run of Cobertura to calculate coverage. In the documentation of CTEST_COVERAGE_COMMAND, give a sample .sh file to merge the Cobertura .ser files and generate the XML report from the merged file.
Diffstat (limited to 'Tests/CoberturaCoverage')
-rw-r--r--Tests/CoberturaCoverage/DartConfiguration.tcl.in8
-rw-r--r--Tests/CoberturaCoverage/coverage.xml.in112
-rw-r--r--Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java52
3 files changed, 172 insertions, 0 deletions
diff --git a/Tests/CoberturaCoverage/DartConfiguration.tcl.in b/Tests/CoberturaCoverage/DartConfiguration.tcl.in
new file mode 100644
index 0000000..954f59a
--- /dev/null
+++ b/Tests/CoberturaCoverage/DartConfiguration.tcl.in
@@ -0,0 +1,8 @@
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: ${CMake_SOURCE_DIR}/Testing/CoberturaCoverage
+BuildDirectory: ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
diff --git a/Tests/CoberturaCoverage/coverage.xml.in b/Tests/CoberturaCoverage/coverage.xml.in
new file mode 100644
index 0000000..b3f6691
--- /dev/null
+++ b/Tests/CoberturaCoverage/coverage.xml.in
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
+
+<coverage line-rate="0.7222222222222222" branch-rate="0.875" lines-covered="13" lines-valid="18" branches-covered="7" branches-valid="8" complexity="0.0" version="1.9.4.1" timestamp="1401890139281">
+ <sources>
+ <source>${CMake_BINARY_DIR}/Testing/CoberturaCoverage/src/main/java/</source>
+ </sources>
+ <packages>
+ <package name="org.cmake.Coverage" line-rate="0.7222222222222222" branch-rate="0.875" complexity="0.0">
+ <classes>
+ <class name="org.cmake.Coverage.CoverageTest" filename="org/cmake/CoverageTest.java" line-rate="0.7222222222222222" branch-rate="0.875" complexity="0.0">
+ <methods>
+ <method name="&lt;clinit&gt;" signature="()V" line-rate="1.0" branch-rate="1.0">
+ <lines>
+ <line number="10" hits="2" branch="false"/>
+ <line number="11" hits="2" branch="false"/>
+ </lines>
+ </method>
+ <method name="&lt;init&gt;" signature="()V" line-rate="0.0" branch-rate="1.0">
+ <lines>
+ <line number="8" hits="0" branch="false"/>
+ <line number="12" hits="0" branch="false"/>
+ </lines>
+ </method>
+ <method name="equalsVarOne" signature="(Ljava/lang/String;)Ljava/lang/Boolean;" line-rate="0.6666666666666666" branch-rate="0.5">
+ <lines>
+ <line number="16" hits="2" branch="true" condition-coverage="50% (1/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="50%"/>
+ </conditions>
+ </line>
+ <line number="17" hits="2" branch="false"/>
+ <line number="20" hits="0" branch="false"/>
+ </lines>
+ </method>
+ <method name="equalsVarTwo" signature="(Ljava/lang/String;)Z" line-rate="1.0" branch-rate="1.0">
+ <lines>
+ <line number="26" hits="4" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="27" hits="2" branch="false"/>
+ <line number="30" hits="2" branch="false"/>
+ </lines>
+ </method>
+ <method name="timesIntOne" signature="(Ljava/lang/Integer;)Ljava/lang/Integer;" line-rate="0.0" branch-rate="1.0">
+ <lines>
+ <line number="35" hits="0" branch="false"/>
+ <line number="36" hits="0" branch="false"/>
+ </lines>
+ </method>
+ <method name="whileLoop" signature="(Ljava/lang/Integer;)Z" line-rate="1.0" branch-rate="1.0">
+ <lines>
+ <line number="41" hits="2" branch="false"/>
+ <line number="42" hits="10" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="43" hits="8" branch="false"/>
+ <line number="45" hits="2" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="46" hits="1" branch="false"/>
+ <line number="49" hits="1" branch="false"/>
+ </lines>
+ </method>
+ </methods>
+ <lines>
+ <line number="8" hits="0" branch="false"/>
+ <line number="10" hits="2" branch="false"/>
+ <line number="11" hits="2" branch="false"/>
+ <line number="12" hits="0" branch="false"/>
+ <line number="16" hits="2" branch="true" condition-coverage="50% (1/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="50%"/>
+ </conditions>
+ </line>
+ <line number="17" hits="2" branch="false"/>
+ <line number="20" hits="0" branch="false"/>
+ <line number="26" hits="4" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="27" hits="2" branch="false"/>
+ <line number="30" hits="2" branch="false"/>
+ <line number="35" hits="0" branch="false"/>
+ <line number="36" hits="0" branch="false"/>
+ <line number="41" hits="2" branch="false"/>
+ <line number="42" hits="10" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="43" hits="8" branch="false"/>
+ <line number="45" hits="2" branch="true" condition-coverage="100% (2/2)">
+ <conditions>
+ <condition number="0" type="jump" coverage="100%"/>
+ </conditions>
+ </line>
+ <line number="46" hits="1" branch="false"/>
+ <line number="49" hits="1" branch="false"/>
+ </lines>
+ </class>
+ </classes>
+ </package>
+ </packages>
+</coverage>
diff --git a/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java
new file mode 100644
index 0000000..4fb43c6
--- /dev/null
+++ b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java
@@ -0,0 +1,52 @@
+package org.cmake.Coverage;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.List;
+import java.awt.*;
+
+public class CoverageTest {
+
+ public static String VarOne = "test1";
+ public static String VarTwo = "test2";
+ private Integer IntOne = 4;
+
+ public static Boolean equalsVarOne(String inString) {
+
+ if(VarOne.equals(inString)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public static boolean equalsVarTwo(String inString){
+
+ if(VarTwo.equals(inString)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private Integer timesIntOne(Integer inVal){
+
+ return inVal * IntOne;
+ }
+
+ public static boolean whileLoop(Integer StopInt){
+
+ Integer i = 0;
+ while(i < StopInt){
+ i=i+1;
+ }
+ if (i.equals(5)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}