Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds to generate the report of test code with maven plugin. #99

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions jacoco-maven-plugin.test/it/it-report-with-testcode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
Evgeny Mandrikov - initial API and implementation
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>jacoco</groupId>
<artifactId>setup-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>it-report-with-testcode</artifactId>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<reportTestcode>true</reportTestcode>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
<debuglevel>none</debuglevel>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
public class Example {

public void sayHello() {
System.out.println("Hello world");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import org.junit.Test;

public class ExampleTest {

@Test
public void test() {
new Example().sayHello();
}

}
28 changes: 28 additions & 0 deletions jacoco-maven-plugin.test/it/it-report-with-testcode/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import java.io.*;
import org.codehaus.plexus.util.*;

String html = FileUtils.fileRead( new File( basedir, "target/site/jacoco/default/ExampleTest.html" ) );
if ( html.indexOf( "<span class=\"el_class\">ExampleTest</span>" ) < 0 ) {
throw new RuntimeException( "No test code coverage in html." );
}

String csv = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.csv" ) );
if ( csv.indexOf( ",ExampleTest," ) < 0 ) {
throw new RuntimeException( "No test code coverage in csv." );
}

String xml = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.xml" ) );
if ( xml.indexOf( "<class name=\"ExampleTest\">" ) < 0 ) {
throw new RuntimeException( "No test code coverage in xml." );
}
55 changes: 55 additions & 0 deletions jacoco-maven-plugin.test/it/it-report-without-testcode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
Evgeny Mandrikov - initial API and implementation
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>jacoco</groupId>
<artifactId>setup-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>it-report-without-testcode</artifactId>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
<debuglevel>none</debuglevel>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
public class Example {

public void sayHello() {
System.out.println("Hello world");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import org.junit.Test;

public class ExampleTest {

@Test
public void test() {
new Example().sayHello();
}

}
28 changes: 28 additions & 0 deletions jacoco-maven-plugin.test/it/it-report-without-testcode/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import java.io.*;
import org.codehaus.plexus.util.*;

File html = new File( basedir, "target/site/jacoco/default/ExampleTest.html" );
if ( html.isFile() ) {
throw new RuntimeException( "Test code coverage was not exluded in html." );
}

String csv = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.csv" ) );
if ( csv.indexOf( ",ExampleTest," ) >= 0 ) {
throw new RuntimeException( "Test code coverage was not exluded in csv." );
}

String xml = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.xml" ) );
if ( xml.indexOf( "<class name=\"ExampleTest\">" ) >= 0 ) {
throw new RuntimeException( "Test code coverage was not exluded in xml." );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
invoker.goals = clean test site

# maven-site-plugin 3.0 requires at least Maven 2.2.0
invoker.maven.version = 2.2.0+
58 changes: 58 additions & 0 deletions jacoco-maven-plugin.test/it/it-site-with-testcode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
Evgeny Mandrikov - initial API and implementation
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>jacoco</groupId>
<artifactId>setup-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>it-site-with-testcode</artifactId>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
</plugin>
</plugins>
</build>

<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<reportTestcode>true</reportTestcode>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
public class Example {

public void sayHello() {
System.out.println("Hello world");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import org.junit.Test;

public class ExampleTest {

@Test
public void test() {
new Example().sayHello();
}

}
38 changes: 38 additions & 0 deletions jacoco-maven-plugin.test/it/it-site-with-testcode/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
import java.io.*;
import org.codehaus.plexus.util.*;

String html_index = FileUtils.fileRead( new File( basedir, "target/site/jacoco/default/index.html" ) );
if ( html_index.indexOf( "<a href=\"ExampleTest.html\" class=\"el_class\">ExampleTest</a>" ) < 0 ) {
throw new RuntimeException( "No test code coverage in index.html." );
}

String html_testcode = FileUtils.fileRead( new File( basedir, "target/site/jacoco/default/ExampleTest.html" ) );
if ( html_testcode.indexOf( "<a href=\"ExampleTest.java.html#L14\" class=\"el_method\">ExampleTest()</a>" ) < 0 ) {
throw new RuntimeException( "No test code coverage html." );
}

File html_testcode_src = new File( basedir, "target/site/jacoco/default/ExampleTest.html" );
if ( !html_testcode_src.isFile() ) {
throw new RuntimeException( "No test code source html." );
}

String csv = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.csv" ) );
if ( csv.indexOf( ",ExampleTest," ) < 0 ) {
throw new RuntimeException( "No test code coverage in csv." );
}

String xml = FileUtils.fileRead( new File( basedir, "target/site/jacoco/jacoco.xml" ) );
if ( xml.indexOf( "<class name=\"ExampleTest\">" ) < 0 ) {
throw new RuntimeException( "No test code coverage in xml." );
}
Loading