diff options
author | Kyle Lieber <klieberuni@gmail.com> | 2012-09-26 22:17:16 -0500 |
---|---|---|
committer | Kyle Lieber <klieberuni@gmail.com> | 2012-09-26 22:17:16 -0500 |
commit | 0a9b208c902b10cfe1c18a5a6b65a9188bec33c5 (patch) | |
tree | 3b3c4f929a48221fb804d864ea11a9ced1f79821 /jacoco-maven-plugin.test | |
parent | b3908916b46ad9e7d36af498b99adcd8e735d91e (diff) | |
download | jacoco-0a9b208c902b10cfe1c18a5a6b65a9188bec33c5.tar.gz |
adding test for check goal when coverage checks have not been met
Diffstat (limited to 'jacoco-maven-plugin.test')
9 files changed, 244 insertions, 0 deletions
diff --git a/jacoco-maven-plugin.test/it/it-check-fails-hault/invoker.properties b/jacoco-maven-plugin.test/it/it-check-fails-hault/invoker.properties new file mode 100644 index 00000000..324b5fb9 --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-hault/invoker.properties @@ -0,0 +1 @@ +invoker.buildResult=failure
\ No newline at end of file diff --git a/jacoco-maven-plugin.test/it/it-check-fails-hault/pom.xml b/jacoco-maven-plugin.test/it/it-check-fails-hault/pom.xml new file mode 100644 index 00000000..576a72ba --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-hault/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2009, 2012 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-check-fails-hault</artifactId> + + <build> + <plugins> + <plugin> + <groupId>@project.groupId@</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>check</id> + <goals> + <goal>check</goal> + </goals> + <configuration> + <check> + <classRate>100</classRate> + <instructionRate>100</instructionRate> + <methodRate>100</methodRate> + <branchRate>100</branchRate> + <complexityRate>100</complexityRate> + <lineRate>100</lineRate> + </check> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/jacoco-maven-plugin.test/it/it-check-fails-hault/src/main/java/Example.java b/jacoco-maven-plugin.test/it/it-check-fails-hault/src/main/java/Example.java new file mode 100644 index 00000000..e54505fd --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-hault/src/main/java/Example.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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"); + } + +} diff --git a/jacoco-maven-plugin.test/it/it-check-fails-hault/src/test/java/ExampleTest.java b/jacoco-maven-plugin.test/it/it-check-fails-hault/src/test/java/ExampleTest.java new file mode 100644 index 00000000..9030020a --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-hault/src/test/java/ExampleTest.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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(); + } + +} diff --git a/jacoco-maven-plugin.test/it/it-check-fails-hault/verify.bsh b/jacoco-maven-plugin.test/it/it-check-fails-hault/verify.bsh new file mode 100644 index 00000000..59221fa2 --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-hault/verify.bsh @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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 buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); +if ( buildLog.indexOf( "Coverage checks have not been met." ) < 0 ) { + throw new RuntimeException( "Coverage checks should not have been met." ); +} + +if ( buildLog.indexOf( "Insufficient code coverage for" ) < 0 ) { + throw new RuntimeException( "Should have displayed insufficient code coverage messages." ); +} + +if ( buildLog.indexOf( "BUILD FAILURE" ) < 0 ) { + throw new RuntimeException( "Build failed but it should have succeeded." ); +} + diff --git a/jacoco-maven-plugin.test/it/it-check-fails-no-hault/pom.xml b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/pom.xml new file mode 100644 index 00000000..d6b0bf2a --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/pom.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2009, 2012 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-check-fails-no-hault</artifactId> + + <build> + <plugins> + <plugin> + <groupId>@project.groupId@</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>check</id> + <goals> + <goal>check</goal> + </goals> + <configuration> + <haltOnFailure>false</haltOnFailure> + <check> + <classRate>100</classRate> + <instructionRate>100</instructionRate> + <methodRate>100</methodRate> + <branchRate>100</branchRate> + <complexityRate>100</complexityRate> + <lineRate>100</lineRate> + </check> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/main/java/Example.java b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/main/java/Example.java new file mode 100644 index 00000000..e54505fd --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/main/java/Example.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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"); + } + +} diff --git a/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/test/java/ExampleTest.java b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/test/java/ExampleTest.java new file mode 100644 index 00000000..9030020a --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/src/test/java/ExampleTest.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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(); + } + +} diff --git a/jacoco-maven-plugin.test/it/it-check-fails-no-hault/verify.bsh b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/verify.bsh new file mode 100644 index 00000000..7c8d6c14 --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-check-fails-no-hault/verify.bsh @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 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 buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); +if ( buildLog.indexOf( "Coverage checks have not been met." ) < 0 ) { + throw new RuntimeException( "Coverage checks should not have been met." ); +} + +if ( buildLog.indexOf( "Insufficient code coverage for" ) < 0 ) { + throw new RuntimeException( "Should have displayed insufficient code coverage messages." ); +} + +if ( buildLog.indexOf( "BUILD SUCCESS" ) < 0 ) { + throw new RuntimeException( "Build failed but it should have succeeded." ); +} + |