http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java new file mode 100644 index 0000000..6ee87fb --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java @@ -0,0 +1,75 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.VerificationException; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1209">SUREFIRE-1209</a> + * @since 2.19 + */ +public class Surefire1209RerunAndForkCountIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void reusableForksJUnit47() + throws VerificationException + { + unpack().executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void notReusableForksJUnit47() + throws VerificationException + { + unpack().reuseForks( false ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void reusableForksJUnit4() + throws VerificationException + { + unpack().addGoal( "-Pjunit4" ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + @Test + public void notReusableForksJUnit4() + throws VerificationException + { + unpack().addGoal( "-Pjunit4" ) + .reuseForks( false ) + .executeTest() + .assertTestSuiteResults( 5, 0, 0, 0, 4 ); + } + + private SurefireLauncher unpack() + { + return unpack( "surefire-1209-rerun-and-forkcount" ); + } +}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java new file mode 100644 index 0000000..53cd764 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java @@ -0,0 +1,62 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; + +/** + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1211">SUREFIRE-1211</a> + * @since 2.19.1 + */ +public class Surefire1211JUnitTestNgIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void withJUnit() + { + assumeJavaVersion( 1.7d ); + + unpack().threadCount( 1 ) + .executeTest() + .verifyErrorFree( 2 ); + } + + @Test + public void withoutJUnit() + { + assumeJavaVersion( 1.7d ); + + unpack().threadCount( 1 ) + .sysProp( "junit", "false" ) + .executeTest() + .verifyErrorFree( 1 ); + } + + private SurefireLauncher unpack() + { + return unpack( "surefire-1211" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java new file mode 100644 index 0000000..c4031c2 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java @@ -0,0 +1,49 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.*; +import org.junit.Test; + +/** + * Added included pattern Tests.java. + * <p> + * Found in Surefire 2.19.1. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1260">SUREFIRE-1260</a> + * @since 2.20 + */ +public class Surefire1260NewTestsPattern + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void defaultConfig() + { + unpack() + .executeTest() + .verifyErrorFree( 5 ); + } + + private SurefireLauncher unpack() + { + return unpack( "/surefire-1260-new-tests-pattern" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java new file mode 100644 index 0000000..bd9af17 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java @@ -0,0 +1,58 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1264">SUREFIRE-1264</a> + * @since 2.20.1 + */ +public class Surefire1264IT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void positiveTests() + { + unpack( "surefire-1264" ) + .setForkJvm() + .parallelAll() + .useUnlimitedThreads() + .sysProp( "canFail", "false" ) + .executeTest() + .assertTestSuiteResults( 16, 0, 0, 0 ); + } + + @Test + public void negativeTests() + { + unpack( "surefire-1264" ) + .setForkJvm() + .parallelAll() + .useUnlimitedThreads() + .sysProp( "canFail", "true" ) + .mavenTestFailureIgnore( true ) + .executeTest() + .assertTestSuiteResults( 16, 0, 16, 0 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java new file mode 100644 index 0000000..2e92805 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java @@ -0,0 +1,57 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.AbstractJigsawIT; +import org.junit.Test; + +import java.io.IOException; + +@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) +/** + * IsolatedClassLoader should take platform ClassLoader as a parent ClassLoader if running on the top of JDK9. + * The IsolatedClassLoader should not fail like this: + * + * [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project + * maven-surefire-plugin-example: Execution default-test of goal + * org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: + * java.lang.NoClassDefFoundError: java/sql/SQLException: java.sql.SQLException -> [Help 1] + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1265">SUREFIRE-1265</a> + * @since 2.20.1 + */ +public class Surefire1265Java9IT + extends AbstractJigsawIT +{ + @Test + public void shouldRunInPluginJava9() throws IOException + { + assumeJigsaw() + .executeTest() + .verifyErrorFree( 2 ); + } + + @Override + protected String getProjectDirectoryName() + { + return "/surefire-1265"; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java new file mode 100644 index 0000000..c0b0339 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * Test the group filter for TestNG + * + */ +public class Surefire1278GroupNameEndingIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testOnlyGroups() + { + unpack().setGroups( "group" ).executeTest().verifyErrorFree( 1 ); + } + + public SurefireLauncher unpack() + { + return unpack( "/surefire-1278-group-name-ending" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java new file mode 100644 index 0000000..3ca758a --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java @@ -0,0 +1,125 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.VerificationException; +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Before; +import org.junit.Test; + +import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC_OSX; +import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +/** + * https://issues.apache.org/jira/browse/SUREFIRE-1295 + * https://github.com/apache/maven-surefire/pull/136 + * + * @author michaeltandy + * @since 2.20 + */ +public class Surefire1295AttributeJvmCrashesToTestsIT + extends SurefireJUnit4IntegrationTestCase +{ + @Before + public void skipWindows() + { + assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX ); + } + + @Test + public void crashInFork() throws VerificationException, InterruptedException + { + SurefireLauncher launcher = unpack( "crash-during-test" ); + + checkCrashTypes( launcher ); + } + + @Test + public void crashInSingleUseFork() throws VerificationException, InterruptedException + { + SurefireLauncher launcher = unpack( "crash-during-test" ) + .forkCount( 1 ) + .reuseForks( false ); + + checkCrashTypes( launcher ); + } + + @Test + public void crashInReusableFork() throws VerificationException, InterruptedException + { + SurefireLauncher launcher = unpack( "crash-during-test" ) + .forkPerThread() + .reuseForks( true ) + .threadCount( 1 ); + + checkCrashTypes( launcher ); + } + + private static void checkCrashTypes( SurefireLauncher launcher ) + throws VerificationException, InterruptedException + { + checkCrash( launcher.addGoal( "-DcrashType=exit" ) ); + checkCrash( launcher.addGoal( "-DcrashType=abort" ) ); + checkCrash( launcher.addGoal( "-DcrashType=segfault" ) ); + } + + private static void checkCrash( SurefireLauncher launcher ) throws VerificationException, InterruptedException + { + OutputValidator validator = launcher.maven() + .withFailure() + .executeTest() + .verifyTextInLog( "The forked VM terminated without properly saying " + + "goodbye. VM crash or System.exit called?" + ) + .verifyTextInLog( "Crashed tests:" ); + + // Cannot flush log.txt stream because it is consumed internally by Verifier. + // Waiting for the stream to become flushed on disk. + TimeUnit.SECONDS.sleep( 1L ); + + for ( Iterator<String> it = validator.loadLogLines().iterator(); it.hasNext(); ) + { + String line = it.next(); + if ( line.contains( "Crashed tests:" ) ) + { + line = it.next(); + if ( it.hasNext() ) + { + assertThat( line ).contains( "junit44.environment.BasicTest" ); + } + else + { + fail( "Could not find any line after 'Crashed tests:'." ); + } + } + } + + } + + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java new file mode 100644 index 0000000..d13b0f2 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1364SystemPropertiesIT.java @@ -0,0 +1,203 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * Report XML should contain system properties of forked JVM. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.20.1 + */ +public class Surefire1364SystemPropertiesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void junit3Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit3" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit3InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit3" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit4Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit4InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit47Forked() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit47InProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit47ForkedParallel() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "once" ) + .parallelClasses() + .threadCount( 2 ) + .disablePerCoreThreadCount() + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void junit47InProcessParallel() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "junit47" ) + .forkMode( "never" ) + .parallelClasses() + .threadCount( 2 ) + .disablePerCoreThreadCount() + .executeTest() + .verifyErrorFree( 2 ); + + validator.getSurefireReportsXmlFile( "TEST-FirstTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + + validator.getSurefireReportsXmlFile( "TEST-SecondTest.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void testNg() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "testng" ) + .forkMode( "once" ) + .executeTest() + .verifyErrorFree( 3 ); + + validator.getSurefireReportsXmlFile( "TEST-TestSuite.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } + + @Test + public void testNgInProcess() + { + SurefireLauncher launcher = unpack( "surefire-1364" ); + OutputValidator validator = launcher.setForkJvm() + .activateProfile( "testng" ) + .forkMode( "never" ) + .executeTest() + .verifyErrorFree( 3 ); + + validator.getSurefireReportsXmlFile( "TEST-TestSuite.xml" ) + .assertContainsText( "<property name=\"forkedProp\" value=\"forkedValue1\"/>" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java new file mode 100644 index 0000000..48564fb --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1367AssumptionLogsIT.java @@ -0,0 +1,157 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1367">SUREFIRE-1367</a> + * @since 2.20.1 + */ +public class Surefire1367AssumptionLogsIT + extends SurefireJUnit4IntegrationTestCase +{ + private static final String NL = System.getProperty( "line.separator" ); + + @Test + public void shouldSeeLogsParallelForked() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "once" ) + .parallelClassesAndMethods() + .disablePerCoreThreadCount() + .threadCountClasses( 2 ) + .threadCountMethods( 2 ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsParallelInPlugin() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "never" ) + .parallelClassesAndMethods() + .disablePerCoreThreadCount() + .threadCountClasses( 2 ) + .threadCountMethods( 2 ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsForked() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "once" ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + @Test + public void shouldSeeLogsInPlugin() + { + OutputValidator outputValidator = unpack().setForkJvm() + .forkMode( "never" ) + .executeTest() + .assertTestSuiteResults( 2, 0, 0, 2 ); + + verifyReportA( outputValidator ); + verifyReportB( outputValidator ); + } + + + private SurefireLauncher unpack() + { + return unpack( "/surefire-1367" ); + } + + private void verifyReportA( OutputValidator outputValidator ) + { + String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-ATest.xml" ) + .readFileToString(); + + String outputCData = "<system-out><![CDATA[Hi" + NL + + NL + + "There!" + NL + + "]]></system-out>" + NL + + " <system-err><![CDATA[Hello" + NL + + NL + + "What's up!" + NL + + "]]></system-err>"; + + assertThat( xmlReport ) + .contains( outputCData ); + + + String output = outputValidator.getSurefireReportsFile( "ATest-output.txt" ) + .readFileToString(); + + String outputExpected = "Hi" + NL + + NL + + "There!" + NL + + "Hello" + NL + + NL + + "What's up!" + NL; + + assertThat( output ) + .isEqualTo( outputExpected ); + } + + private void verifyReportB( OutputValidator outputValidator ) + { + String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-BTest.xml" ) + .readFileToString(); + + String outputCData = "<system-out><![CDATA[Hey" + NL + + NL + + "you!" + NL + + "]]></system-out>"; + + assertThat( xmlReport ) + .contains( outputCData ); + + + String output = outputValidator.getSurefireReportsFile( "BTest-output.txt" ) + .readFileToString(); + + String outputExpected = "Hey" + NL + + NL + + "you!" + NL; + + assertThat( output ) + .isEqualTo( outputExpected ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java new file mode 100644 index 0000000..4a27688 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java @@ -0,0 +1,52 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.VerificationException; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Jonathan Bell + */ +public class Surefire1396CustomProviderClassPathIT + extends SurefireJUnit4IntegrationTestCase +{ + @BeforeClass + public static void installProvider() + throws VerificationException + { + unpack( Surefire1396CustomProviderClassPathIT.class, "surefire-1396-pluggableproviders-classpath-provider", "prov" ).executeInstall(); + } + + @Test + public void pluggableProviderClasspathCorrect() + throws Exception + { + unpack( "surefire-1396-pluggableproviders-classpath" ) + .setForkJvm() + .maven() + .showExceptionMessages() + .debugLogging() + .executeVerify() + .verifyErrorFreeLog(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java new file mode 100644 index 0000000..b185217 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java @@ -0,0 +1,179 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.VerificationException; +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireVerifierException; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.FilenameFilter; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * SUREFIRE-613 Asserts proper test counts when running in parallel + * + * @author Kristian Rosenvold + */ +public class Surefire141PluggableProvidersIT + extends SurefireJUnit4IntegrationTestCase +{ + @BeforeClass + public static void installProvider() + throws VerificationException + { + unpack( Surefire141PluggableProvidersIT.class, "surefire-141-pluggableproviders-provider", "prov" ) + .executeInstall(); + } + + @Test + public void pluggableProviderPresent() + throws Exception + { + unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() + .maven() + .showExceptionMessages() + .debugLogging() + .executeTest() + .verifyTextInLog( "Using configured provider org.apache.maven.surefire.testprovider.TestProvider" ) + .verifyTextInLog( "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" ) + .verifyErrorFreeLog(); + } + + @Test + public void invokeRuntimeException() + throws Exception + { + final String errorText = "Let's fail with a runtimeException"; + + OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() + .sysProp( "invokeCrash", "runtimeException" ) + .maven() + .withFailure() + .executeTest(); + + assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); + boolean verifiedInLog = verifiedErrorInLog( validator, errorText ); + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) + .isTrue(); + } + + @Test + public void invokeReporterException() + throws Exception + { + final String errorText = "Let's fail with a reporterexception"; + + OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() + .sysProp( "invokeCrash", "reporterException" ) + .maven() + .withFailure() + .executeTest(); + + assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); + boolean verifiedInLog = verifiedErrorInLog( validator, errorText ); + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) + .isTrue(); + } + + @Test + public void constructorRuntimeException() + throws Exception + { + final String errorText = "Let's fail with a runtimeException"; + + OutputValidator validator = unpack( "surefire-141-pluggableproviders" ) + .setForkJvm() + .sysProp( "constructorCrash", "runtimeException" ) + .maven() + .withFailure() + .executeTest(); + + assertErrorMessage( validator, errorText ); + + boolean hasErrorInLog = verifiedErrorInLog( validator, "There was an error in the forked process" ); + boolean verifiedInLog = verifiedErrorInLog( validator, errorText ); + assertThat( hasErrorInLog && verifiedInLog ) + .describedAs( "'" + errorText + "' could not be verified in log.txt nor *.dump file. (" + + hasErrorInLog + ", " + verifiedInLog + ")" ) + .isTrue(); + } + + private static void assertErrorMessage( OutputValidator validator, String message ) + { + File reportDir = validator.getSurefireReportsDirectory(); + String[] dumpFiles = reportDir.list( new FilenameFilter() + { + @Override + public boolean accept( File dir, String name ) + { + return name.endsWith( ".dump" ); + } + }); + assertThat( dumpFiles ).isNotEmpty(); + for ( String dump : dumpFiles ) + { + validator.getSurefireReportsFile( dump ) + .assertContainsText( message ); + } + } + + private static boolean verifiedErrorInLog( OutputValidator validator, String errorText ) + { + try + { + validator.verifyTextInLog( errorText ); + return true; + } + catch ( SurefireVerifierException e ) + { + return false; + } + } + + private static boolean verifiedErrorInDump( OutputValidator validator, String errorText ) + { + try + { + assertErrorMessage( validator, errorText ); + return true; + } + catch ( AssertionError e ) + { + return false; + } + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java new file mode 100644 index 0000000..7e50f25 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire146ForkPerTestNoSetupIT.java @@ -0,0 +1,38 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * Test Surefire-146 (forkMode=pertest fails to call setUp) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire146ForkPerTestNoSetupIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testForkPerTestNoSetup() + { + executeErrorFreeTest( "surefire-146-forkPerTestNoSetup", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java new file mode 100644 index 0000000..e13483a --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire162CharsetProviderIT.java @@ -0,0 +1,51 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.surefire.its.fixture.*; +import org.codehaus.plexus.util.FileUtils; +import org.junit.Test; + +/** + * Test charset provider (SUREFIRE-162) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire162CharsetProviderIT + extends SurefireJUnit4IntegrationTestCase +{ + @SuppressWarnings( { "ResultOfMethodCallIgnored" } ) + @Test + public void testCharsetProvider() + throws Exception + { + SurefireLauncher unpack = unpack( "/surefire-162-charsetProvider" ); + MavenLauncher maven = unpack.maven(); + OutputValidator verifier = maven.getValidator(); + File jarFile = maven.getArtifactPath( "jcharset", "jcharset", "1.2.1", "jar" ); + File pomFile = maven.getArtifactPath( "jcharset", "jcharset", "1.2.1", "pom" ); + jarFile.getParentFile().mkdirs(); + FileUtils.copyFile( verifier.getSubFile( "repo/jcharset/jcharset/1.2.1/jcharset-1.2.1.jar" ), jarFile ); + FileUtils.copyFile( verifier.getSubFile( "repo/jcharset/jcharset/1.2.1/jcharset-1.2.1.pom" ), pomFile ); + unpack.executeTest().verifyErrorFree( 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java new file mode 100644 index 0000000..1bdb3cb --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java @@ -0,0 +1,78 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.plugins.surefire.report.ReportTestCase; +import org.apache.maven.plugins.surefire.report.ReportTestSuite; +import org.apache.maven.surefire.its.fixture.HelperAssertions; +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +/** + * Test Surefire-224 (XML test reports are not well-formed when failure message contains quotes) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire224WellFormedXmlFailuresIT + extends SurefireJUnit4IntegrationTestCase +{ + @SuppressWarnings("ConstantConditions") + @Test + public void testWellFormedXmlFailures() + { + OutputValidator outputValidator = unpack( "/surefire-224-wellFormedXmlFailures" ).executeTest(); + + outputValidator.assertTestSuiteResults( 4, 0, 4, 0 ); + + ReportTestSuite suite = HelperAssertions.extractReports( outputValidator.getBaseDir() ).get( 0 ); + List<org.apache.maven.plugins.surefire.report.ReportTestCase> testCases = suite.getTestCases(); + assertEquals( "Wrong number of test case objects", 4, testCases.size() ); + ReportTestCase testQuote = null, testLower = null, testGreater = null, testU0000 = null; + for ( ReportTestCase current : testCases ) + { + if ( "testQuote".equals( current.getName() ) ) + { + testQuote = current; + } + else if ( "testLower".equals( current.getName() ) ) + { + testLower = current; + } + else if ( "testGreater".equals( current.getName() ) ) + { + testGreater = current; + } + else if ( "testU0000".equals( current.getName() ) ) + { + testU0000 = current; + } + } + assertEquals( "Wrong error message", "\"", testQuote.getFailureMessage() ); + assertEquals( "Wrong error message", "<", testLower.getFailureMessage() ); + assertEquals( "Wrong error message", ">", testGreater.getFailureMessage() ); + // SUREFIRE-456 we have to doubly-escape non-visible control characters like \u0000 + assertEquals( "Wrong error message", "�", testU0000.getFailureMessage() ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java new file mode 100644 index 0000000..2796b92 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire257NotRerunningTestsIT.java @@ -0,0 +1,41 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * Test Surefire-257 Verifies that surefire does not re-run tests in site build + * + * @author Kristian Rosenvold + */ +public class Surefire257NotRerunningTestsIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void shouldNotRerun() + throws Exception + { + unpack( + "/surefire-257-rerunningTests" ).addSurefireReportGoal().addSurefireReportGoal().executeCurrentGoals().verifyTextInLog( + "Skipping execution of surefire because it has already been run for this configuration" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java new file mode 100644 index 0000000..aab3380 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire260TestWithIdenticalNamesIT.java @@ -0,0 +1,72 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.net.URI; + +import org.apache.maven.surefire.its.fixture.*; + +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlAnchor; +import com.gargoylesoftware.htmlunit.html.HtmlDivision; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Test Surefire-570 Multiple report directories + * + * @author Kristian Rosenvold + */ +public class Surefire260TestWithIdenticalNamesIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void testWithIdenticalNames() + throws IOException + { + SurefireLauncher surefireLauncher = unpack( "surefire-260-testWithIdenticalNames" ).failNever(); + surefireLauncher.executeTest(); + surefireLauncher.reset(); + OutputValidator validator = surefireLauncher.addSurefireReportGoal().executeCurrentGoals(); + + TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); + final URI uri = siteFile.toURI(); + + final WebClient webClient = new WebClient(); + webClient.setJavaScriptEnabled( true ); + final HtmlPage page = webClient.getPage( uri.toURL() ); + + final HtmlAnchor a = + (HtmlAnchor) page.getByXPath( "//a[@href = \"javascript:toggleDisplay('surefire260.TestB.testDup');\"]" ) + .get( 0 ); + final HtmlDivision content = (HtmlDivision) page.getElementById( "surefire260.TestB.testDup-failure" ); + assertNotNull( content ); + assertTrue( content.getAttribute( "style" ).contains( "none" ) ); + a.click(); + assertFalse( content.getAttribute( "style" ).contains( "none" ) ); + webClient.closeAllWindows(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java new file mode 100644 index 0000000..bb80aec --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire34SecurityManagerIT.java @@ -0,0 +1,48 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel + * + * @author Kristian Rosenvold + */ +public class Surefire34SecurityManagerIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testSecurityManager() + { + SurefireLauncher surefireLauncher = unpack( "surefire-34-securityManager" ).failNever(); + surefireLauncher.executeTest().assertTestSuiteResults( 2, 1, 0, 0 ); + } + + @Test + public void testSecurityManagerSuccessful() + { + SurefireLauncher surefireLauncher = unpack( "surefire-34-securityManager-success" ); + surefireLauncher.executeTest().assertTestSuiteResults( 2, 0, 0, 0 ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java new file mode 100644 index 0000000..ebc0e1e --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire376TestNgAfterSuiteFailureIT.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * Test Surefire-376 (TestNG @AfterSuite failures are ignored) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire376TestNgAfterSuiteFailureIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testAfterSuiteFailure() + { + unpack( "/testng-afterSuiteFailure" ) + .maven() + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .withFailure() + .executeTest() + .assertTestSuiteResults( 2, 0, 1, 0 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java new file mode 100644 index 0000000..a29d030 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java @@ -0,0 +1,52 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * SUREFIRE-377 (When JUnit and TestNG tests are in same project, only one set gets run). + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire377TestNgAndJUnitTogetherIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testTestNgAndJUnitTogether() + { + unpack( "/testng-junit-together" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 2 ); + } + + @Test + public void testTestNgAndJUnit4Together() + { + unpack( "/testng-junit4-together" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFree( 3 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java new file mode 100644 index 0000000..3287ab4 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java @@ -0,0 +1,42 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * SUREFIRE-613 Asserts proper test counts when running in parallel + * + * @author Kristian Rosenvold + */ +public class Surefire408ManualProviderSelectionIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testParallelBuildResultCount() + { + unpack( "/surefire-408-manual-provider-selection" ) + .showErrorStackTraces() + .debugLogging() + .executeTest() + .verifyTextInLog( "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java new file mode 100644 index 0000000..00c2aee --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire42NotExtendingTestCaseIT.java @@ -0,0 +1,38 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * Test JUnit test that contains inner classes + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire42NotExtendingTestCaseIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testInnerClass() + { + executeErrorFreeTest( "junit-notExtendingTestCase", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java new file mode 100644 index 0000000..928019a --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire44InnerClassTestIT.java @@ -0,0 +1,38 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * Test JUnit test that contains inner classes + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class Surefire44InnerClassTestIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testInnerClass() + { + executeErrorFreeTest( "/junit-innerClass", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java new file mode 100644 index 0000000..9356f68 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire500PuzzlingErrorIT.java @@ -0,0 +1,42 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.TestFile; +import org.junit.Test; + +/** + * SUREFIRE-500 Asserts correct error handling for the "odd" surefire-500 (and 625) issues. + * + * @author Kristian Rosenvold + */ +public class Surefire500PuzzlingErrorIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testBuildFailingWhenErrors() + { + OutputValidator outputValidator = unpack( "/surefire-500-puzzling-error" ).failNever().executeTest(); + TestFile surefireReportsFile = outputValidator.getSurefireReportsFile( "surefire500.ExplodingTest.txt" ); + surefireReportsFile.assertContainsText( "java.lang.NoClassDefFoundError: whoops!" ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java new file mode 100644 index 0000000..4e4fd13 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire510TestClassPathForkModesIT.java @@ -0,0 +1,53 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * SUREFIRE-621 Asserts proper test counts when running junit 3 tests in parallel + * + * @author Kristian Rosenvold + */ +public class Surefire510TestClassPathForkModesIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void testForkAlways() + { + unpack().forkAlways().executeTest(). + verifyTextInLog( "tcp is set" ); + } + + @Test + public void testForkOnce() + { + unpack().forkOnce().executeTest(). + verifyTextInLog( "tcp is set" ); + } + + public SurefireLauncher unpack() + { + return unpack( "/surefire-510-testClassPath" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java new file mode 100644 index 0000000..3e53cca --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire569RunTestFromDependencyJarsIT.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Test; + +/** + * SUREFIRE-569 Add support for scanning Dependencies for TestClasses + * + * @author Aslak Knutsen + */ +public class Surefire569RunTestFromDependencyJarsIT + extends SurefireJUnit4IntegrationTestCase { + + @Test + public void shouldScanAndRunTestsInDependencyJars() throws Exception { + SurefireLauncher launcher = unpack( "surefire-569-RunTestFromDependencyJars" ); + launcher.addGoal("test").addGoal("install"); + launcher.executeCurrentGoals(); + + OutputValidator module1 = launcher.getSubProjectValidator("module1"); + module1.assertTestSuiteResults(1, 0, 0, 0); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java new file mode 100644 index 0000000..a9b437e --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire570MultipleReportDirectoriesIT.java @@ -0,0 +1,68 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.*; +import org.junit.Test; + +/** + * Test Surefire-570 Multiple report directories + * + * @author Kristian Rosenvold + */ +public class Surefire570MultipleReportDirectoriesIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void testReportWithAggregate() + throws Exception + { + + SurefireLauncher surefireLauncher = unpack().failNever(); + surefireLauncher.executeTest(); + surefireLauncher.addGoal( "-Daggregate=true" ); + OutputValidator validator = surefireLauncher.executeSurefireReport( ); + TestFile siteFile = validator.getSiteFile( "surefire-report.html" ); + siteFile.assertContainsText( "MyModule1ClassTest" ); + siteFile.assertContainsText( "MyModule2ClassTest" ); + siteFile.assertContainsText( "MyDummyClassM1Test" ); + } + + @Test + public void testReportWithoutAggregate() + throws Exception + { + SurefireLauncher surefireLauncher = unpack().failNever(); + surefireLauncher.executeTest(); + surefireLauncher.reset(); + surefireLauncher.executeSurefireReport( ); + OutputValidator module1 = surefireLauncher.getSubProjectValidator( "module1" ); + TestFile siteFile = module1.getSiteFile( "surefire-report.html" ); + siteFile.assertContainsText( "MyModule1ClassTest" ); + siteFile.assertContainsText( "MyDummyClassM1Test" ); + } + + public SurefireLauncher unpack() + { + return unpack( "/surefire-570-multipleReportDirectories" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java new file mode 100644 index 0000000..7b74409 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire613TestCountInParallelIT.java @@ -0,0 +1,45 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * SUREFIRE-613 Asserts proper test counts when running in parallel + * + * @author Kristian Rosenvold + */ +public class Surefire613TestCountInParallelIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testParallelBuildResultCount() + { + OutputValidator validator = unpack( "/surefire-613-testCount-in-parallel" ).failNever().executeTest(); + + validator.verifyTextInLog( "testAllok to stdout" ); + validator.verifyTextInLog( "testAllok to stderr" ); + validator.verifyTextInLog( "testWithException1 to stdout" ); + validator.verifyTextInLog( "testWithException1 to stderr" ); + validator.assertTestSuiteResults( 30, 8, 4, 17 ); + } +}