Navigation Menu

Skip to content

Commit

Permalink
Add tycho-emma-coverage-plugin
Browse files Browse the repository at this point in the history
Add EmmaAutomationMojo which uses tycho.testArgLine to automatically configure
the
bundle to instrument and to exclude the test classes from instrumentation.
For details and usage see included integration test.
Adding org.eclemma.runtime.equinox bundle as resource for the integration test
here since it is not available in a public maven repo. See
https://docs.sonatype.org/display/TYCHO/How+to+integrate+EMMA+%28code+coverage%29+with+Tycho
which explains how to repackage the offical eclemma.zip.
Discussion with Dave Meibusch how to update the wiki-page pending.
  • Loading branch information
jsievers committed Jul 30, 2010
0 parents commit 27154cb
Show file tree
Hide file tree
Showing 23 changed files with 1,203 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
/target
/.settings
/.project
/.classpath
5 changes: 5 additions & 0 deletions its/.gitignore
@@ -0,0 +1,5 @@
/target
/.settings
/.classpath
/.project
/workspace
179 changes: 179 additions & 0 deletions its/pom.xml
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-extras</artifactId>
<version>0.10.0-SNAPSHOT</version>
</parent>
<artifactId>tycho-extras-its</artifactId>

<name>Tycho Extras Integration Tests</name>

<properties>
<tycho-build-version>${project.version}</tycho-build-version>
<maven-dir>${project.build.directory}/apache-maven-${maven-version}</maven-dir>
</properties>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>maven-properties-plugin</artifactId>
<version>0.0.2</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<goals>
<goal>filter-file</goal>
</goals>
<configuration>
<in>src/test/resources/baseTest.properties</in>
<outDir>target/test-classes/</outDir>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-maven</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>apache-maven</includeArtifactIds>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<failIfNoTests>true</failIfNoTests>
<systemPropertyVariables>
<it.cliOptions>${it.cliOptions}</it.cliOptions>
</systemPropertyVariables>
</configuration>
</plugin>

</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>${maven-version}</version>
<classifier>bin</classifier>
<type>tar.gz</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-p2-runtime</artifactId>
<version>${tycho-build-version}</version>
<type>zip</type>
</dependency>

<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<version>1.2</version>
</dependency>


<!-- artifacts to be tested -->
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-osgi-components</artifactId>
<version>${tycho-build-version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-tycho-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-compiler-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-packaging-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-test-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-source-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-build-version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho</artifactId>
<version>${tycho-build-version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-its</artifactId>
<version>0.10.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: bundle.test;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Activator: bundle.test.Activator
Bundle-ActivationPolicy: lazy
Fragment-Host: bundle
Require-Bundle: system.bundle,
org.junit4;bundle-version="4.0.0",
org.eclipse.core.runtime;bundle-version="3.4.0"
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
62 changes: 62 additions & 0 deletions its/projects/TYCHO406testArgLineConfiguration/bundle.test/pom.xml
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>TYCHO406emmaAutomation</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<packaging>eclipse-test-plugin</packaging>
<artifactId>bundle.test</artifactId>

<build>
<plugins>
<plugin>
<!--
we just use this here to convert the *.es file into an *.xml
file for better validation.
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>emma</groupId>
<artifactId>emma_ant</artifactId>
<version>2.0.5312</version>
</dependency>
<dependency>
<groupId>emma</groupId>
<artifactId>emma</artifactId>
<version>2.0.5312</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>emma-report</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="emma_ant.properties" />
<echo>Process emma report...</echo>
<emma enabled="true">
<report>
<infileset dir="${project.build.directory}/" includes="*.es" />
<txt outfile="${project.build.directory}/coverage.txt" />
<xml outfile="${project.build.directory}/coverage.xml" />
<!-- Could also generate an HTML report, if you want... -->
</report>
</emma>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,14 @@
package bundle.test;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TestClass {

@Test
public void simpleTest() {
ClassUnderTest cut = new ClassUnderTest();
assertEquals(42, cut.add(39,3));
}
}
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bundle
Bundle-SymbolicName: bundle
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
15 changes: 15 additions & 0 deletions its/projects/TYCHO406testArgLineConfiguration/bundle/pom.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>TYCHO406emmaAutomation</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<packaging>eclipse-plugin</packaging>

<artifactId>bundle</artifactId>

</project>
@@ -0,0 +1,14 @@
package bundle.test;

/**
* Dummy class for checking coverage automation
*/
public class ClassUnderTest {
public int add(int a, int b) {
return a+b;
}

public int subtract(int a, int b) {
return a-b;
}
}
Binary file not shown.
38 changes: 38 additions & 0 deletions its/projects/TYCHO406testArgLineConfiguration/eclemma/pom.xml
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.eclemma.runtime</groupId>
<artifactId>org.eclemma.runtime.equinox</artifactId>
<version>1.1.0.200908261008</version>

<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>org.eclemma.runtime.equinox-1.1.0.200908261008.jar</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>

0 comments on commit 27154cb

Please sign in to comment.