Skip to content

Commit 4d1ea78

Browse files
author
Ian Craggs
committed
Add jacoco code coverage measurements to tests
1 parent 7b9a209 commit 4d1ea78

9 files changed

Lines changed: 185 additions & 7 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ before_install:
2121
script:
2222
- mvn -B clean -q
2323
- mvn -B --projects org.eclipse.paho.client.mqttv3,org.eclipse.paho.client.mqttv3.test test -q
24-
- mvn -B --projects org.eclipse.paho.mqttv5.common,org.eclipse.paho.mqttv5.client test -q
24+
- mvn -B --projects org.eclipse.paho.mqttv5.common,org.eclipse.paho.mqttv5.client,org.eclipse.paho.mqttv5.client.test test -q
2525

2626
#addons:
2727
# apt:

org.eclipse.paho.client.mqttv3.test/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@
6060
<forkCount>1</forkCount>
6161
</configuration>
6262
</plugin>
63+
<plugin>
64+
<groupId>org.jacoco</groupId>
65+
<artifactId>jacoco-maven-plugin</artifactId>
66+
<version>${jacoco.version}</version>
67+
<executions>
68+
<execution>
69+
<goals>
70+
<goal>prepare-agent</goal>
71+
</goals>
72+
</execution>
73+
<execution>
74+
<id>generate-test-report</id>
75+
<phase>test</phase>
76+
<goals>
77+
<goal>report-aggregate</goal>
78+
</goals>
79+
</execution>
80+
</executions>
81+
</plugin>
6382
</plugins>
6483
</build>
6584

org.eclipse.paho.client.mqttv3/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212

1313
<build>
1414
<plugins>
15+
<plugin>
16+
<groupId>org.jacoco</groupId>
17+
<artifactId>jacoco-maven-plugin</artifactId>
18+
<version>${jacoco.version}</version>
19+
<executions>
20+
<execution>
21+
<goals>
22+
<goal>prepare-agent</goal>
23+
</goals>
24+
</execution>
25+
</executions>
26+
</plugin>
1527
<plugin>
1628
<groupId>org.eclipse.tycho</groupId>
1729
<artifactId>tycho-maven-plugin</artifactId>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.eclipse.paho</groupId>
7+
<artifactId>java-parent</artifactId>
8+
<version>1.2.1-SNAPSHOT</version>
9+
</parent>
10+
<groupId>org.eclipse.paho.mqttv5.client.test</groupId>
11+
<artifactId>org.eclipse.paho.mqttv5.client.test</artifactId>
12+
<version>1.2.1-SNAPSHOT</version>
13+
<name>org.eclipse.paho.mqttv5.client.test</name>
14+
<url>http://maven.apache.org</url>
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>org.jacoco</groupId>
23+
<artifactId>jacoco-maven-plugin</artifactId>
24+
<version>${jacoco.version}</version>
25+
<executions>
26+
<execution>
27+
<goals>
28+
<goal>prepare-agent</goal>
29+
</goals>
30+
</execution>
31+
<execution>
32+
<id>generate-test-report</id>
33+
<phase>test</phase>
34+
<goals>
35+
<goal>report-aggregate</goal>
36+
</goals>
37+
</execution>
38+
</executions>
39+
</plugin>
40+
</plugins>
41+
</build>
42+
43+
<dependencies>
44+
<dependency>
45+
<groupId>junit</groupId>
46+
<artifactId>junit</artifactId>
47+
<version>3.8.1</version>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.eclipse.paho</groupId>
52+
<artifactId>org.eclipse.paho.mqttv5.common</artifactId>
53+
<version>1.2.1-SNAPSHOT</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.eclipse.paho</groupId>
57+
<artifactId>org.eclipse.paho.mqttv5.client</artifactId>
58+
<version>1.2.1-SNAPSHOT</version>
59+
</dependency>
60+
</dependencies>
61+
62+
<packaging>pom</packaging>
63+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.org.eclipse.paho.mqttv5.client.test;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.org.eclipse.paho.mqttv5.client.test;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
extends TestCase
12+
{
13+
/**
14+
* Create the test case
15+
*
16+
* @param testName name of the test case
17+
*/
18+
public AppTest( String testName )
19+
{
20+
super( testName );
21+
}
22+
23+
/**
24+
* @return the suite of tests being tested
25+
*/
26+
public static Test suite()
27+
{
28+
return new TestSuite( AppTest.class );
29+
}
30+
31+
/**
32+
* Rigourous Test :-)
33+
*/
34+
public void testApp()
35+
{
36+
assertTrue( true );
37+
}
38+
}

org.eclipse.paho.mqttv5.client/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@
5151
</dependencies>
5252
<build>
5353
<plugins>
54+
<plugin>
55+
<groupId>org.jacoco</groupId>
56+
<artifactId>jacoco-maven-plugin</artifactId>
57+
<version>${jacoco.version}</version>
58+
<executions>
59+
<execution>
60+
<goals>
61+
<goal>prepare-agent</goal>
62+
</goals>
63+
</execution>
64+
<execution>
65+
<id>generate-test-report</id>
66+
<phase>test</phase>
67+
<goals>
68+
<goal>report-aggregate</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
5473
<plugin>
5574
<groupId>org.apache.maven.plugins</groupId>
5675
<artifactId>maven-compiler-plugin</artifactId>

org.eclipse.paho.mqttv5.common/pom.xml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@
2424

2525
<build>
2626
<plugins>
27+
<plugin>
28+
<groupId>org.jacoco</groupId>
29+
<artifactId>jacoco-maven-plugin</artifactId>
30+
<version>${jacoco.version}</version>
31+
<executions>
32+
<execution>
33+
<goals>
34+
<goal>prepare-agent</goal>
35+
</goals>
36+
</execution>
37+
</executions>
38+
</plugin>
2739
<plugin>
2840
<groupId>org.apache.maven.plugins</groupId>
29-
<artifactId>maven-compiler-plugin</artifactId>
30-
<version>3.7.0</version>
31-
<configuration>
32-
<source>1.8</source>
33-
<target>1.8</target>
34-
</configuration>
41+
<artifactId>maven-compiler-plugin</artifactId>
42+
<version>3.7.0</version>
43+
<configuration>
44+
<source>1.8</source>
45+
<target>1.8</target>
46+
</configuration>
3547
</plugin>
3648
</plugins>
3749
</build>

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<junit.version>4.12</junit.version>
1818
<javadoc.version>3.0.1</javadoc.version>
1919
<mvnsource.version>3.0.1</mvnsource.version>
20+
<jacoco.version>0.8.2</jacoco.version>
2021
<test.exclude>**/*ConformantTest.java</test.exclude>
2122
<download.location>/home/data/httpd/download.eclipse.org/paho/releases/${project.version}/Java</download.location>
2223
</properties>
@@ -306,5 +307,6 @@
306307
<module>org.eclipse.paho.sample.utility</module>
307308
<module>org.eclipse.paho.mqttv5.common</module>
308309
<module>org.eclipse.paho.mqttv5.client</module>
310+
<module>org.eclipse.paho.mqttv5.client.test</module>
309311
</modules>
310312
</project>

0 commit comments

Comments
 (0)