http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java new file mode 100644 index 0000000..0819196 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AdditionalClasspathIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 additionalClasspathElements + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class AdditionalClasspathIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void additionalClasspath() + { + unpack( "/additional-classpath" ).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/AggregateReportIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java new file mode 100644 index 0000000..ab8f64c --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java @@ -0,0 +1,57 @@ +package org.apache.maven.surefire.its; + +/* + * 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.IntegrationTestSuiteResults; +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; + +import static org.apache.maven.surefire.its.fixture.HelperAssertions.parseTestResults; +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assertTestSuiteResults; +import static org.junit.Assert.assertTrue; + +/** + * Test report aggregation + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class AggregateReportIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void aggregateReport() + { + OutputValidator outputValidator = unpack( "/aggregate-report" ).addSurefireReportGoal().executeCurrentGoals(); + TestFile surefireReportHtml = outputValidator.getSiteFile( "surefire-report.html" ); + assertTrue( "surefire report missing: " + surefireReportHtml.getAbsolutePath(), surefireReportHtml.exists() ); + + // TODO HtmlUnit tests on the surefire report + + IntegrationTestSuiteResults suite = parseTestResults( new File( outputValidator.getBaseDir(), "child1" ), + new File( outputValidator.getBaseDir(), "child2" ) ); + assertTestSuiteResults( 2, 0, 1, 0, suite ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java new file mode 100644 index 0000000..c1ad8f7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLineIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 passing an argLine parameter + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class ArgLineIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void argLine() + { + unpack( "/argLine-parameter" ).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/ArgLinePropertiesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java new file mode 100644 index 0000000..cf1074e --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ArgLinePropertiesIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 passing an argLine parameter + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class ArgLinePropertiesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void argLine() + { + unpack( "/argLine-properties" ).executeTest().verifyErrorFree( 4 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java new file mode 100644 index 0000000..856cd8c --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AssumptionFailureReportIT.java @@ -0,0 +1,34 @@ +package org.apache.maven.surefire.its; +/* + * 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; + +public class AssumptionFailureReportIT extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testWriteSkippedMessageToReport() + { + final OutputValidator outputValidator = unpack( "/assumpationFailureReport" ).executeTest(); + TestFile xmlReportFile = outputValidator.getSurefireReportsXmlFile( "TEST-assumptionFailure.Test1.xml" ); + xmlReportFile.assertContainsText( "The test is skipped if it is false" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java new file mode 100644 index 0000000..85d0f95 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java @@ -0,0 +1,70 @@ +package org.apache.maven.surefire.its; + +/* + * 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; + +import static org.junit.Assert.assertFalse; + +/** + * Test running a single test with -Dtest=BasicTest + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckSingleTestIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void singleTest() + { + unpack().setTestToRun( "BasicTest" ).executeTest().verifyErrorFree( 1 ); + } + + @Test + public void singleTestDotJava() + { + unpack().setTestToRun( "BasicTest.java" ).executeTest().verifyErrorFree( 1 ); + } + + @Test + public void singleTestNonExistent() + { + final OutputValidator output = unpack().setTestToRun( "DoesNotExist" ).maven().withFailure().executeTest(); + TestFile reportsDir = output.getTargetFile( "surefire-reports" ); + assertFalse( "Unexpected reports directory", reportsDir.exists() ); + } + + @Test + public void singleTestNonExistentOverride() + { + final OutputValidator output = + unpack().setTestToRun( "DoesNotExist" ).failIfNoTests( false ).executeTest().verifyErrorFreeLog(); + output.getTargetFile( "surefire-reports" ); + // assertFalse( "Unexpected reports directory", reportsDir.exists() ); Hmpf. Not really a good test + } + + private SurefireLauncher unpack() + { + return unpack( "/default-configuration" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkModeIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkModeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkModeIT.java new file mode 100644 index 0000000..6e2a67a --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsForkModeIT.java @@ -0,0 +1,81 @@ +package org.apache.maven.surefire.its; + +/* + * 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 failIfNoTests with various forkModes. + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestFailIfNoTestsForkModeIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void failIfNoTestsForkModeAlways() + { + unpack().forkAlways().failIfNoTests( true ).maven().withFailure().executeTest(); + } + + @Test + public void failIfNoTestsForkModeNever() + { + unpack().forkNever().failIfNoTests( true ).maven().withFailure().executeTest(); + } + + @Test + public void failIfNoTestsForkModeOnce() + { + unpack().forkOnce().failIfNoTests( true ).maven().withFailure().executeTest(); + } + + @Test + public void dontFailIfNoTestsForkModeAlways() + { + doTest( unpack().forkAlways().failIfNoTests( false ) ); + } + + @Test + public void dontFailIfNoTestsForkModeNever() + { + doTest( unpack().forkNever().failIfNoTests( false ) ); + } + + @Test + public void dontFailIfNoTestsForkModeOnce() + { + doTest( unpack().forkOnce().failIfNoTests( false ) ); + } + + private void doTest( SurefireLauncher launcher ) + { + launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 0, 0, 0, 0 ); + } + + private SurefireLauncher unpack() + { + return unpack( "default-configuration-classWithNoTests" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java new file mode 100644 index 0000000..787037c --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestFailIfNoTestsIT.java @@ -0,0 +1,63 @@ +package org.apache.maven.surefire.its; + +/* + * 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; + +import static org.junit.Assert.assertFalse; + +/** + * Test failIfNoTests + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestFailIfNoTestsIT + extends SurefireJUnit4IntegrationTestCase +{ + private SurefireLauncher unpack() + { + return unpack( "/default-configuration-noTests" ); + } + + @Test + public void failIfNoTests() + { + unpack().failIfNoTests( true ).maven().withFailure().executeTest(); + } + + @Test + public void dontFailIfNoTests() + { + final OutputValidator outputValidator = unpack().failIfNoTests( false ).executeTest(); + outputValidator.verifyErrorFreeLog(); + TestFile reportsDir = outputValidator.getSurefireReportsFile( "" ); + assertFalse( "Unexpected reports directory", reportsDir.exists() ); + } + + @Test + public void jUnit48CategoriesFailWhenNoTests() + { + unpack().failIfNoTests( false ).activateProfile( "junit47" ).setJUnitVersion( + "4.8.1" ).executeTest().verifyErrorFreeLog(); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java new file mode 100644 index 0000000..440955c --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodFailureIT.java @@ -0,0 +1,47 @@ +package org.apache.maven.surefire.its; + +/* + * 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 failures in @BeforeMethod annotation on TestNg suite + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestNgBeforeMethodFailureIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void TestNgBeforeMethodFailure() + throws Exception + { + unpack( "/testng-beforeMethodFailure" ) + .maven() + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .withFailure() + .executeTest() + .assertTestSuiteResults( 2, 0, 1, 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java new file mode 100644 index 0000000..d96fefc --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgBeforeMethodIT.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its; + +/* + * 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 @BeforeMethod annotation on TestNg suite + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestNgBeforeMethodIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void TestNgBeforeMethod() + throws Exception + { + unpack( "/testng-beforeMethod" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .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/CheckTestNgCustomObjectFactoryIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java new file mode 100644 index 0000000..2e2b646 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomObjectFactoryIT.java @@ -0,0 +1,58 @@ +package org.apache.maven.surefire.its; +/* + * 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 java.io.File; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * Test TestNG with custom object factory defined. + * + * @author <a href="mailto:or...@codehaus.org">Orien Madgwick</a> + */ +public class CheckTestNgCustomObjectFactoryIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testTestNgListenerReporter() + throws Exception + { + File baseDir = unpack() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 1, 0, 0, 0 ) + .getBaseDir(); + + baseDir = baseDir.getCanonicalFile(); + + File targetDir = new File( baseDir, "target" ); + assertThat( targetDir ).isDirectory(); + assertThat( new File( targetDir, "objectFactory-output.txt" ) ).isFile(); + } + + private SurefireLauncher unpack() + { + return unpack( "/testng-objectFactory" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java new file mode 100644 index 0000000..4cf5afa --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgCustomTestRunnerFactoryIT.java @@ -0,0 +1,59 @@ +package org.apache.maven.surefire.its; +/* + * 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 java.io.File; + +import static org.fest.assertions.Assertions.assertThat; + +/** + * Test TestNG with custom test runner factory defined. + * + * @author <a href="mailto:or...@codehaus.org">Orien Madgwick</a> + */ +public class CheckTestNgCustomTestRunnerFactoryIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testTestNgListenerReporter() + throws Exception + { + File baseDir = unpack() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 1, 0, 0, 0 ) + .getBaseDir(); + + baseDir = baseDir.getCanonicalFile(); + + File targetDir = new File( baseDir, "target" ); + assertThat( targetDir ).isDirectory(); + assertThat( new File( targetDir, "testrunnerfactory-output.txt" ) ).isFile(); + } + + private SurefireLauncher unpack() + { + return unpack( "/testng-testRunnerFactory" ); + } +} + http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java new file mode 100644 index 0000000..24ee3e6 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java @@ -0,0 +1,69 @@ +package org.apache.maven.surefire.its; + +/* + * 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; + +import java.io.File; +import java.io.FilenameFilter; + +import static org.fest.assertions.Assertions.assertThat; + + +/** + * Test for checking that the output from a forked suite is properly captured even if the suite encounters a severe error. + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestNgExecuteErrorIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void executionError() + throws Exception + { + OutputValidator outputValidator = unpack( "/testng-execute-error" ) + .maven() + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .showErrorStackTraces() + .withFailure() + .executeTest(); + + File reportDir = outputValidator.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 ) + { + outputValidator.getSurefireReportsFile( dump ) + .assertContainsText( "at org.apache.maven.surefire.testng.TestNGExecutor.run" ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java new file mode 100644 index 0000000..f56e2e4 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgGroupThreadParallelIT.java @@ -0,0 +1,43 @@ +package org.apache.maven.surefire.its; + +/* + * 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 TestNG groups, together with TestNG parallelism + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestNgGroupThreadParallelIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void TestNgGroupThreadParallel() + { + unpack( "testng-group-thread-parallel" ) + .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/CheckTestNgJdk14IT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java new file mode 100644 index 0000000..9cabd7e --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgJdk14IT.java @@ -0,0 +1,41 @@ +package org.apache.maven.surefire.its; + +/* + * 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 TestNG running in the JDK 1.4 JavaDoc style + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class CheckTestNgJdk14IT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void TestNgJdk14() + throws Exception + { + unpack( "/testng-jdk14" ).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/CheckTestNgListenerReporterIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java new file mode 100644 index 0000000..2c618d0 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java @@ -0,0 +1,105 @@ +package org.apache.maven.surefire.its; + +/* + * 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 org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.Arrays; +import java.util.Collection; + +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; +import static org.junit.runners.Parameterized.Parameter; +import static org.junit.runners.Parameterized.Parameters; + +/** + * Test simple TestNG listener and reporter + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +@RunWith( Parameterized.class ) +public class CheckTestNgListenerReporterIT + extends SurefireJUnit4IntegrationTestCase +{ + @Parameters( name = "{index}: TestNG {0}" ) + public static Collection<Object[]> data() + { + return Arrays.asList(new Object[][] { + { "5.6", "jdk15", 1.5d }, // First TestNG version with reporter support + { "5.7", "jdk15", 1.5d }, // default version from pom of the test case + { "5.10", "jdk15", 1.5d }, + { "5.13", null, 1.5d }, // "reporterslist" param becomes String instead of List<ReporterConfig> + // "listener" param becomes String instead of List<Class> + + // configure(Map) in 5.14.1 and 5.14.2 is transforming List<Class> into a String with a space as separator. + // Then configure(CommandLineArgs) splits this String into a List<String> with , or ; as separator => fail. + // If we used configure(CommandLineArgs), we would not have the problem with white spaces. + //{ "5.14.1", null, "1.5" }, // "listener" param becomes List instead of String + // Fails: Issue with 5.14.1 and 5.14.2 => join with <space>, split with "," + // TODO will work with "configure(CommandLineArgs)" + //{ "5.14.2", null, "1.5" }, // ReporterConfig is not available + + //{ "5.14.3", null, "1.5" }, // TestNG uses "reporter" instead of "reporterslist" + // Both String or List are possible for "listener" + // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI + // ClassNotFoundException: com.beust.jcommander.ParameterException + + //{ "5.14.4", null, "1.5" }, { "5.14.5", null, "1.5" }, // Fails: not able to test due to system dependency org.testng:guice missed the path and use to break CI + // ClassNotFoundException: com.beust.jcommander.ParameterException + + { "5.14.6", null, 1.5d }, // Usage of org.testng:guice removed + { "5.14.9", null, 1.5d }, // Latest 5.14.x TestNG version + { "6.0", null, 1.5d }, + { "6.9.9", null, 1.7d } // Currently latest TestNG version + }); + } + + @Parameter + public String version; + + @Parameter(1) + public String classifier; + + @Parameter(2) + public double javaVersion; + + @Test + public void testNgListenerReporter() + { + assumeJavaVersion( javaVersion ); + final SurefireLauncher launcher = unpack( "testng-listener-reporter", "_" + version ) + .sysProp( "testNgVersion", version ); + + if ( classifier != null ) + { + launcher.sysProp( "testNgClassifier", "jdk15" ); + } + + launcher.executeTest() + .verifyErrorFree( 1 ) + .getTargetFile( "resultlistener-output.txt" ).assertFileExists() + .getTargetFile( "suitelistener-output.txt" ).assertFileExists() + .getTargetFile( "reporter-output.txt" ).assertFileExists(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java new file mode 100644 index 0000000..cc1bb74 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenersIT.java @@ -0,0 +1,37 @@ +package org.apache.maven.surefire.its; + +/* + * 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 annotation-based TestNG listener + */ +public class CheckTestNgListenersIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void TestNgListenerReporter() + { + unpack( "testng-listeners" ).mavenTestFailureIgnore( true ).executeTest().assertTestSuiteResults( 1, 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/CheckTestNgPathWithSpacesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java new file mode 100644 index 0000000..aa77d1b --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgPathWithSpacesIT.java @@ -0,0 +1,42 @@ +package org.apache.maven.surefire.its; + +/* + * 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 TestNG test in a directory with spaces + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class CheckTestNgPathWithSpacesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void TestWithSpaces() + { + unpack( "testng-path with spaces" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .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/CheckTestNgReportTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java new file mode 100644 index 0000000..a358172 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java @@ -0,0 +1,74 @@ +package org.apache.maven.surefire.its; + +/* + * 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; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; + +/** + * Test surefire-report on TestNG test + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class CheckTestNgReportTestIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testNgReport() + throws Exception + { + unpack( "/testng-simple" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .addSurefireReportGoal() + .executeCurrentGoals() + .verifyErrorFree( 3 ) + .getSiteFile( "surefire-report.html" ) + .assertFileExists(); + } + + @Test + public void shouldNotBeVerbose() + throws Exception + { + unpack( "/testng-simple" ) + .sysProp( "testNgVersion", "5.10" ) + .sysProp( "testNgClassifier", "jdk15" ) + .executeTest() + .verifyErrorFreeLog() + .assertThatLogLine( containsString( "[Parser] Running:" ), is( 0 ) ); + } + + @Test + public void shouldBeVerbose() + throws Exception + { + unpack( "/testng-simple" ) + .sysProp( "testNgVersion", "5.10" ) + .sysProp( "testNgClassifier", "jdk15" ) + .sysProp( "surefire.testng.verbose", "10" ) + .executeTest() + .verifyErrorFreeLog() + .assertThatLogLine( containsString( "[Parser] Running:" ), is( 1 ) ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java new file mode 100644 index 0000000..2e56dc9 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlIT.java @@ -0,0 +1,60 @@ +package org.apache.maven.surefire.its; + +/* + * 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.Ignore; +import org.junit.Test; + +/** + * Test simple TestNG suite XML file + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class CheckTestNgSuiteXmlIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void suiteXml() + { + unpack().executeTest().verifyErrorFree( 2 ); + } + + @Test + @Ignore( "Fails - see SUREFIRE-1123" ) + public void suiteXmlForkModeAlways() + { + unpack().forkAlways().executeTest().verifyErrorFree( 2 ); + } + + @Test + public void suiteXmlForkCountTwoReuse() + { + unpack().forkCount( 2 ).reuseForks( true ).executeTest().verifyErrorFree( 2 ); + } + + private SurefireLauncher unpack() + { + return unpack( "testng-suite-xml" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java new file mode 100644 index 0000000..e2b63b6 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its; + +/* + * 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; + +/** + * Use -Dtest to run a single TestNG test, overriding the suite XML parameter. + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class CheckTestNgSuiteXmlSingleIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void TestNgSuite() + { + unpack( "/testng-twoTestCaseSuite" ) + .sysProp( "testNgVersion", "5.7" ) + .sysProp( "testNgClassifier", "jdk15" ) + .setTestToRun( "TestNGTestTwo" ) + .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/CheckTestNgVersionsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java new file mode 100644 index 0000000..6d2bbfa --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java @@ -0,0 +1,223 @@ +package org.apache.maven.surefire.its; + +/* + * 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.util.List; + +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.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Basic suite test using all known versions of TestNG. Used for regression testing Surefire against old versions. To + * check new versions of TestNG work with current versions of Surefire, instead run the full test suite with + * -Dtestng.version=5.14.2 (for example) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CheckTestNgVersionsIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test public void test47() + throws Exception + { + runTestNgTest( "4.7", "jdk15" ); + } + + @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest50() + throws Exception + { + runTestNgTest( "5.0", "jdk15" ); + } + + @Test @Ignore( "5.0 and 5.0.1 jars on central are malformed SUREFIRE-375 + MAVENUPLOAD-1024" ) public void XXXtest501() + throws Exception + { + runTestNgTest( "5.0.1", "jdk15" ); + } + + @Test public void test502() + throws Exception + { + runTestNgTest( "5.0.2", "jdk15" ); + } + + @Test public void test51() + throws Exception + { + runTestNgTest( "5.1", "jdk15" ); + } + + @Test public void test55() + throws Exception + { + runTestNgTest( "5.5", "jdk15" ); + } + + @Test public void test56() + throws Exception + { + runTestNgTest( "5.6", "jdk15" ); + } + + @Test public void test57() + throws Exception + { + runTestNgTest( "5.7", "jdk15" ); + } + + @Test public void test58() + throws Exception + { + runTestNgTest( "5.8", "jdk15" ); + } + + @Test public void test59() + throws Exception + { + runTestNgTest( "5.9", "jdk15" ); + } + + @Test public void test510() + throws Exception + { + runTestNgTest( "5.10", "jdk15" ); + } + + @Test public void test511() + throws Exception + { + runTestNgTest( "5.11", "jdk15" ); + } + + @Test public void test512() + throws Exception + { + runTestNgTest( "5.12.1" ); + } + + @Test public void test513() + throws Exception + { + runTestNgTest( "5.13" ); + } + + @Test public void test5131() + throws Exception + { + runTestNgTest( "5.13.1" ); + } + + @Test public void test514() + throws Exception + { + runTestNgTest( "5.14" ); + } + + @Test public void test5141() + throws Exception + { + runTestNgTest( "5.14.1" ); + } + + @Test public void test5142() + throws Exception + { + runTestNgTest( "5.14.2" ); + } + + @Test public void test60() + throws Exception + { + runTestNgTest( "6.0" ); + } + + @Test public void test685() + throws Exception + { + runTestNgTestWithRunOrder( "6.8.5" ); + } + + private void runTestNgTestWithRunOrder( String version ) + throws Exception + { + runTestNgTest( version, null, true ); + } + + private void runTestNgTest( String version ) + throws Exception + { + runTestNgTest( version, null, false ); + } + + private void runTestNgTest( String version, boolean validateRunOrder ) + throws Exception + { + runTestNgTest( version, null, validateRunOrder ); + } + + private void runTestNgTest( String version, String classifier ) + throws Exception + { + runTestNgTest( version, classifier, false ); + } + + private void runTestNgTest( String version, String classifier, boolean validateRunOrder ) + throws Exception + { + final SurefireLauncher launcher = unpack( "testng-simple" ) + .sysProp( "testNgVersion", version ); + + if ( classifier != null ) + { + launcher.sysProp( "testNgClassifier", classifier ); + } + + final OutputValidator outputValidator = launcher.executeTest(); + + outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 ); + + if ( validateRunOrder ) + { + // assert correct run order of tests + List<ReportTestSuite> report = HelperAssertions.extractReports( outputValidator.getBaseDir() ); + + assertEquals( 3, report.size() ); + + assertTrue( "TestNGSuiteTestC was executed first", getTestClass( report, 0 ).endsWith( "TestNGSuiteTestC" ) ); + assertTrue( "TestNGSuiteTestB was executed second", getTestClass( report, 1 ).endsWith( "TestNGSuiteTestB" ) ); + assertTrue( "TestNGSuiteTestA was executed last", getTestClass( report, 2 ).endsWith( "TestNGSuiteTestA" ) ); + } + } + + private String getTestClass( List<ReportTestSuite> report, int i ) + { + return report.get( i ).getFullClassName(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java new file mode 100644 index 0000000..dfea90a --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClassPathOrderIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 for checking the order of class path elements + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class ClassPathOrderIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void classPathOrder() + { + unpack( "/classpath-order" ).executeTest().verifyErrorFree( 2 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java new file mode 100644 index 0000000..89aada7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathFilteringIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 additionalClasspathElements + * + * @author pgier + */ +public class ClasspathFilteringIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void additionalClasspath() + throws Exception + { + unpack( "classpath-filtering" ).debugLogging().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/ClasspathScopeFilteringIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java new file mode 100644 index 0000000..ca64d87 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ClasspathScopeFilteringIT.java @@ -0,0 +1,39 @@ +package org.apache.maven.surefire.its; + +/* + * 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 additionalClasspathElements + * + * @author pgier + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class ClasspathScopeFilteringIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void additionalClasspath() + { + unpack( "classpath-scope-filtering" ).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/ConsoleOutputIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java new file mode 100644 index 0000000..e01d798 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java @@ -0,0 +1,106 @@ +package org.apache.maven.surefire.its; + +/* + * 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.nio.charset.Charset; + +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; + +/** + * Basic suite test using all known versions of JUnit 4.x + * + * @author Kristian Rosenvold + */ +public class ConsoleOutputIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void properNewlinesAndEncodingWithDefaultEncodings() + { + final OutputValidator outputValidator = + unpack( "/consoleOutput" ).forkOnce().executeTest(); + + validate( outputValidator, true ); + } + + @Test + public void properNewlinesAndEncodingWithDifferentEncoding() + { + final OutputValidator outputValidator = + unpack( "/consoleOutput" ).forkOnce().argLine( "-Dfile.encoding=UTF-16" ).executeTest(); + + validate( outputValidator, true ); + } + + @Test + public void properNewlinesAndEncodingWithoutFork() + { + final OutputValidator outputValidator = + unpack( "/consoleOutput" ).forkNever().executeTest(); + + validate( outputValidator, false ); + } + + private void validate( final OutputValidator outputValidator, boolean includeShutdownHook ) + { + TestFile xmlReportFile = outputValidator.getSurefireReportsXmlFile( "TEST-consoleOutput.Test1.xml" ); + xmlReportFile.assertContainsText( "SoutLine" ); + xmlReportFile.assertContainsText( normalizeToDefaultCharset( "äöüÃ" ) ); + xmlReportFile.assertContainsText( normalizeToDefaultCharset( "failing with ü" ) ); + + TestFile outputFile = outputValidator.getSurefireReportsFile( "consoleOutput.Test1-output.txt" ); + outputFile.assertContainsText( "SoutAgain" ); + outputFile.assertContainsText( "SoutLine" ); + outputFile.assertContainsText( normalizeToDefaultCharset( "äöüÃ" ) ); + + if ( includeShutdownHook ) + { + outputFile.assertContainsText( "Printline in shutdown hook" ); + } + } + + /** + * @param string the string to normalize + * @return the string with all characters not available in the current charset being replaced, e.g. for US-ASCII, + * German umlauts would be replaced to ? + */ + private String normalizeToDefaultCharset( String string ) + { + Charset cs = Charset.defaultCharset(); + if ( cs.canEncode() ) + { + string = cs.decode( cs.encode( string ) ).toString(); + } + + return string; + } + + @Test + public void largerSoutThanMemory() + throws Exception + { + unpack( "consoleoutput-noisy" ).setMavenOpts( "-Xmx64m" ).sysProp( "thousand", "32000" ).executeTest(); + } + + +} \ 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/CrashDetectionIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java new file mode 100644 index 0000000..b5489d1 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CrashDetectionIT.java @@ -0,0 +1,61 @@ +package org.apache.maven.surefire.its; + +/* + * 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:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class CrashDetectionIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void crashInFork() + { + unpack( "crash-detection" ).maven().withFailure().executeTest(); + } + + @Test + public void crashInReusableFork() + { + unpack( "crash-detection" ) + .forkPerThread() + .reuseForks( true ) + .threadCount( 1 ) + .maven() + .withFailure() + .executeTest(); + } + + @Test + public void hardCrashInReusableFork() + { + unpack( "crash-detection" ) + .forkPerThread() + .reuseForks( true ) + .threadCount( 1 ) + .addGoal( "-DkillHard=true" ) + .maven() + .withFailure() + .executeTest(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java new file mode 100644 index 0000000..b0907b8 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/DefaultConfigurationIT.java @@ -0,0 +1,38 @@ +package org.apache.maven.surefire.its; + +/* + * 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 basic default configuration, runs the JUnit 3 test in the src/test directory. + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class DefaultConfigurationIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void defaultConfiguration() + { + executeErrorFreeTest( "default-configuration", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java new file mode 100644 index 0000000..7f38a73 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariableIT.java @@ -0,0 +1,40 @@ +package org.apache.maven.surefire.its; + +/* + * 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 basic default configuration, runs the JUnit 3 test in the src/test directory. + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class EnvironmentVariableIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void environmentVariable() + { + + executeErrorFreeTest( "junit44-environment", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java new file mode 100644 index 0000000..651200f --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/EnvironmentVariablesIT.java @@ -0,0 +1,47 @@ +package org.apache.maven.surefire.its; + +/* + * 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-763 Asserts that environment variables are correctly populated using "useSystemClassLoader=false" + * SUREFIRE-963 Asserts that empty environment variables are read as "". + * + * @author Kristian Rosenvold + * @author Christophe Deneux + */ +public class EnvironmentVariablesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testWhenUseSystemClassLoader() + { + unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=true" ).executeTest(); + } + + @Test + public void testWhenDontUseSystemClassLoader() + { + unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=false" ).executeTest(); + } + +} \ 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/FailFastJUnitIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java new file mode 100644 index 0000000..beb1e32 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java @@ -0,0 +1,77 @@ +package org.apache.maven.surefire.its; + +/* + * 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.util.ArrayList; + +import static org.junit.runners.Parameterized.Parameters; + +/** + * Test class for SUREFIRE-580, configuration parameter {@code skipAfterFailureCount}. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.19 + */ +public class FailFastJUnitIT + extends AbstractFailFastIT +{ + + @Parameters(name = "{0}") + public static Iterable<Object[]> data() + { + /** + * reuseForks=false is not used because of race conditions and unpredictable commands received by + * MasterProcessReader, this feature has significant limitation. + */ + ArrayList<Object[]> args = new ArrayList<Object[]>(); + // description + // profile + // forkCount, + // fail-fast-count, + // reuseForks + // total + // failures + // errors + // skipped + args.add( new Object[] { "junit4-oneFork-ff1", "junit4", props( 1, 1, true ), 5, 0, 1, 4 } ); + args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1, true ), 5, 0, 1, 4 } ); + args.add( new Object[] { "junit4-oneFork-ff2", "junit4", props( 1, 2, true ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2, true ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit4-twoForks-ff1", "junit4", props( 2, 1, true ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit47-twoForks-ff1", "junit47",props( 2, 1, true ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit4-twoForks-ff2", "junit4", props( 2, 2, true ), 5, 0, 2, 2 } ); + args.add( new Object[] { "junit47-twoForks-ff2", "junit47",props( 2, 2, true ), 5, 0, 2, 2 } ); + args.add( new Object[] { "junit4-oneFork-ff3", "junit4", props( 1, 3, true ), 5, 0, 2, 0 } ); + args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3, true ), 5, 0, 2, 0 } ); + args.add( new Object[] { "junit4-twoForks-ff3", "junit4", props( 2, 3, true ), 5, 0, 2, 0 } ); + args.add( new Object[] { "junit47-twoForks-ff3", "junit47",props( 2, 3, true ), 5, 0, 2, 0 } ); + /*args.add( new Object[] { "junit4-twoForks-ff1x","junit4", props( 2, 1, false ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit47-twoForks-ff1x","junit47",props( 2, 1, false ), 5, 0, 2, 3 } ); + args.add( new Object[] { "junit4-twoForks-ff2x","junit4", props( 2, 2, false ), 5, 0, 2, 2 } ); + args.add( new Object[] { "junit47-twoForks-ff2x","junit47",props( 2, 2, false ), 5, 0, 2, 2 } );*/ + return args; + } + + @Override + protected String withProvider() + { + return "junit"; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java new file mode 100644 index 0000000..f4aa2b7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java @@ -0,0 +1,69 @@ +package org.apache.maven.surefire.its; + +/* + * 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.util.ArrayList; + +import static org.junit.runners.Parameterized.Parameters; + +/** + * Test class for SUREFIRE-580, configuration parameter {@code skipAfterFailureCount}. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.19 + */ +public class FailFastTestNgIT + extends AbstractFailFastIT +{ + + @Parameters(name = "{0}") + public static Iterable<Object[]> data() + { + /** + * reuseForks=false is not used because of race conditions and unpredictable commands received by + * MasterProcessReader, this feature has significant limitation. + */ + ArrayList<Object[]> args = new ArrayList<Object[]>(); + // description + // profile + // forkCount, + // fail-fast-count, + // reuseForks + // total + // failures + // errors + // skipped + args.add( new Object[] { "testng-oneFork-ff1", null, props( 1, 1, true ), 5, 1, 0, 4 } ); + args.add( new Object[] { "testng-oneFork-ff2", null, props( 1, 2, true ), 5, 2, 0, 3 } ); + args.add( new Object[] { "testng-twoForks-ff1", null, props( 2, 1, true ), 5, 2, 0, 3 } ); + args.add( new Object[] { "testng-twoForks-ff2", null, props( 2, 2, true ), 5, 2, 0, 2 } ); + args.add( new Object[] { "testng-oneFork-ff3", null, props( 1, 3, true ), 5, 2, 0, 0 } ); + args.add( new Object[] { "testng-twoForks-ff3", null, props( 2, 3, true ), 5, 2, 0, 0 } ); + /*args.add( new Object[] { "testng-twoForks-ff1x", null, props( 2, 1, false ), 5, 2, 0, 3 } ); + args.add( new Object[] { "testng-twoForks-ff2x", null, props( 2, 2, false ), 5, 2, 0, 2 } );*/ + return args; + } + + @Override + protected String withProvider() + { + return "testng"; + } +}