http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java deleted file mode 100644 index 2669b2f..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1082ParallelJUnitParameterizedIT.java +++ /dev/null @@ -1,212 +0,0 @@ -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.apache.maven.surefire.its.fixture.TestFile; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.junit.Test; - -import java.nio.charset.Charset; -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -import static org.hamcrest.core.AnyOf.anyOf; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.StringContains.containsString; -import static org.junit.Assert.assertThat; - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1082">SUREFIRE-1082</a> - * @since 2.18 - */ -public class Surefire1082ParallelJUnitParameterizedIT - extends SurefireJUnit4IntegrationTestCase -{ - private static Set<String> printOnlyTestLinesFromConsole( OutputValidator validator ) - throws VerificationException - { - return printOnlyTestLines( validator.loadLogLines() ); - } - - private static Set<String> printOnlyTestLinesFromOutFile( OutputValidator validator ) - throws VerificationException - { - TestFile report = validator.getSurefireReportsFile( "jiras.surefire1082.Jira1082Test-output.txt" ); - report.assertFileExists(); - return printOnlyTestLines( validator.loadFile( report.getFile(), Charset.forName( "UTF-8" ) ) ); - } - - private static Set<String> printOnlyTestLines( Collection<String> logs ) - throws VerificationException - { - Set<String> log = new TreeSet<String>(); - for ( String line : logs ) - { - if ( line.startsWith( "class jiras.surefire1082." ) ) - { - log.add( line ); - } - } - return log; - } - - private static Matcher<Set<String>> regex( Set<String> r ) - { - return new IsRegex( r ); - } - - private static void assertParallelRun( Set<String> log ) - { - assertThat( log.size(), is( 4 ) ); - - Set<String> expectedLogs1 = new TreeSet<String>(); - expectedLogs1.add( "class jiras.surefire1082.Jira1082Test a 0 pool-[\\d]+-thread-1" ); - expectedLogs1.add( "class jiras.surefire1082.Jira1082Test b 0 pool-[\\d]+-thread-1" ); - expectedLogs1.add( "class jiras.surefire1082.Jira1082Test a 1 pool-[\\d]+-thread-2" ); - expectedLogs1.add( "class jiras.surefire1082.Jira1082Test b 1 pool-[\\d]+-thread-2" ); - - Set<String> expectedLogs2 = new TreeSet<String>(); - expectedLogs2.add( "class jiras.surefire1082.Jira1082Test a 1 pool-[\\d]+-thread-1" ); - expectedLogs2.add( "class jiras.surefire1082.Jira1082Test b 1 pool-[\\d]+-thread-1" ); - expectedLogs2.add( "class jiras.surefire1082.Jira1082Test a 0 pool-[\\d]+-thread-2" ); - expectedLogs2.add( "class jiras.surefire1082.Jira1082Test b 0 pool-[\\d]+-thread-2" ); - - assertThat( log, anyOf( regex( expectedLogs1 ), regex( expectedLogs2 ) ) ); - } - - @Test - public void checkClassesRunParallel() - throws VerificationException - { - OutputValidator validator = unpack().setTestToRun( "Jira1082Test" ) - .parallelClasses() - .useUnlimitedThreads() - .executeTest() - .verifyErrorFree( 4 ); - - validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) - .assertFileExists(); - - validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); - - Set<String> log = printOnlyTestLinesFromConsole( validator ); - assertParallelRun( log ); - } - - @Test - public void checkOutFileClassesRunParallel() - throws VerificationException - { - OutputValidator validator = unpack().redirectToFile( true ) - .setTestToRun( "Jira1082Test" ) - .parallelClasses() - .useUnlimitedThreads() - .executeTest() - .verifyErrorFree( 4 ); - - validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) - .assertFileExists(); - - validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); - - Set<String> log = printOnlyTestLinesFromOutFile( validator ); - assertParallelRun( log ); - } - - @Test - public void shouldRunTwo() throws VerificationException - { - OutputValidator validator = unpack().redirectToFile( true ) - .parallelClasses() - .useUnlimitedThreads() - .executeTest() - .verifyErrorFree( 8 ); - - validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1082Test.xml" ) - .assertFileExists(); - - validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1082.Jira1264Test.xml" ) - .assertFileExists(); - - validator.getSurefireReportsFile( "jiras.surefire1082.Jira1082Test-output.txt" ) - .assertFileExists(); - - validator.getSurefireReportsFile( "jiras.surefire1082.Jira1264Test-output.txt" ) - .assertFileExists(); - - validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1082Test" ), is( 1 ) ); - - validator.assertThatLogLine( containsString( "Running jiras.surefire1082.Jira1264Test" ), is( 1 ) ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1082-parallel-junit-parameterized" ); - } - - private static class IsRegex - extends BaseMatcher<Set<String>> - { - private final Set<String> expectedRegex; - - IsRegex( Set<String> expectedRegex ) - { - this.expectedRegex = expectedRegex; - } - - @Override - public boolean matches( Object o ) - { - if ( o != null && o instanceof Set ) - { - Set<String> actual = (Set<String>) o; - boolean matches = actual.size() == expectedRegex.size(); - Iterator<String> regex = expectedRegex.iterator(); - for ( String s : actual ) - { - if ( s == null || !regex.hasNext() || !s.matches( regex.next() ) ) - { - matches = false; - } - } - return matches; - } - else - { - return false; - } - } - - @Override - public void describeTo( Description description ) - { - description.appendValue( expectedRegex ); - } - } -}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java deleted file mode 100644 index f894265..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1095NpeInRunListener.java +++ /dev/null @@ -1,94 +0,0 @@ -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; - -@SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } ) -/** - * - * In the surefire plugin, it is possible to specify one or more RunListener when running tests with JUnit. - * However, it does not look like the listener is properly called by the plugin. In particular, there is a problem - * with the method: - * <pre> - * public void testRunStarted(Description description) - * </pre> - * it's javadoc at - * <a href="http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html#testRunStarted%28org.junit.runner.Description%29"/> - * states: - * "Parameters: - * description - describes the tests to be run " - * however, in all maven projects I tried ("mvn test"), the surefire plugin seems like passing a null reference instead - * of a Description instance that "describes the tests to be run " - * Note: other methods in the RunListener I tested seems fine (i.e., they get a valid Description object as input) - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1095}"/> - * @since 2.18 - */ -public final class Surefire1095NpeInRunListener - extends SurefireJUnit4IntegrationTestCase -{ - - /** - * Method Request.classes( String, Class[] ); exists in JUnit 4.0 - 4.4 - * See JUnit4Reflector. - */ - @Test - public void testRunStartedWithJUnit40() - { - unpack().setJUnitVersion( "4.0" ) - .executeTest() - .verifyErrorFree( 1 ) - .verifyTextInLog( "Running JUnit 4.0" ) - .verifyTextInLog( "testRunStarted [jiras.surefire1095.SomeTest]" ); - } - - /** - * Method Request.classes( Class[] ); Since of JUnit 4.5 - * See JUnit4Reflector. - */ - @Test - public void testRunStartedWithJUnit45() - { - unpack().setJUnitVersion( "4.5" ) - .executeTest() - .verifyErrorFree( 1 ) - .verifyTextInLog( "Running JUnit 4.5" ) - .verifyTextInLog( "testRunStarted [jiras.surefire1095.SomeTest]" ); - } - - @Test - public void testRunStartedWithJUnit47() - { - unpack().setJUnitVersion( "4.7" ) - .executeTest() - .verifyErrorFree( 1 ) - .verifyTextInLog( "Running JUnit 4.7" ) - .verifyTextInLog( "testRunStarted [jiras.surefire1095.SomeTest]" ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1095-npe-in-runlistener" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java deleted file mode 100644 index e81f066..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1098BalancedRunOrderIT.java +++ /dev/null @@ -1,119 +0,0 @@ -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.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import static org.junit.Assert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.AnyOf.anyOf; - -/** - * The purpose of this IT is to assert that the run order of test classes is according to the settings:<br> - * - * runOrder=balanced<br> - * parallel=classes<br> - * threadCount=2<br> - * perCoreThreadCount=false<br> - * <br> - * The list of tests should be reordered to (DTest, CTest, BTest, ATest) in the second run. - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1098">SUREFIRE-1098</a> - * @since 2.18 - */ -public class Surefire1098BalancedRunOrderIT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void reorderedParallelClasses() - throws VerificationException - { - SurefireLauncher launcher = unpack(); - - launcher - // .runOrder( "balanced" ) call it in 3.x and remove it in surefire-1098-balanced-runorder/pom.xml - // as soon as there is prefix available "failsafe" and "surefire" in system property for this parameter. - .parallelClasses().threadCount( 2 ).disablePerCoreThreadCount() - .executeTest().verifyErrorFree( 4 ); - - OutputValidator validator = - launcher - // .runOrder( "balanced" ) call it in 3.x and remove it in surefire-1098-balanced-runorder/pom.xml - // as soon as there is prefix available "failsafe" and "surefire" in system property for this parameter. - .parallelClasses().threadCount( 2 ).disablePerCoreThreadCount() - .executeTest().verifyErrorFree( 4 ); - - List<String> log = printOnlyTestLines( validator ); - assertThat( log.size(), is( 4 ) ); - Collections.sort( log ); - final int[] threadPoolIdsOfLongestTest = extractThreadPoolIds( log.get( 3 ) ); - final int pool = threadPoolIdsOfLongestTest[0]; - int thread = threadPoolIdsOfLongestTest[1]; - assertThat( thread, anyOf( is( 1 ), is( 2 ) ) ); - thread = thread == 1 ? 2 : 1; - // If the longest test class DTest is running in pool-2-thread-1, the others should run in pool-2-thread-2 - // and vice versa. - assertThat( log.get( 0 ), is( testLine( "A", pool, thread ) ) ); - assertThat( log.get( 1 ), is( testLine( "B", pool, thread ) ) ); - assertThat( log.get( 2 ), is( testLine( "C", pool, thread ) ) ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1098-balanced-runorder" ); - } - - private static List<String> printOnlyTestLines( OutputValidator validator ) - throws VerificationException - { - List<String> log = new ArrayList<String>( validator.loadLogLines() ); - for ( Iterator<String> it = log.iterator(); it.hasNext(); ) { - String line = it.next(); - if ( !line.startsWith( "class jiras.surefire1098." ) ) { - it.remove(); - } - } - return log; - } - - private static int[] extractThreadPoolIds(String logLine) - { - //Example to parse "class jiras.surefire1098.DTest pool-2-thread-1" into {2, 1}. - String t = logLine.split( " " )[2]; - String[] ids = t.split( "-" ); - return new int[]{ Integer.parseInt( ids[1] ), Integer.parseInt( ids[3] )}; - } - - private String testLine(String test, int pool, int thread) - { - return String.format( "class jiras.surefire1098.%sTest pool-%d-thread-%d", test, pool, thread ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java deleted file mode 100644 index 2f9dca8..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1122ParallelAndFlakyTestsIT.java +++ /dev/null @@ -1,48 +0,0 @@ -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 agudian - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1122">SUREFIRE-1122</a> - */ -public class Surefire1122ParallelAndFlakyTestsIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void nonParallelCreatesCorrectReport() - { - unpack( "surefire-1122-parallel-and-flakyTests" ) - .executeTest() - .assertTestSuiteResults( 2, 0, 0, 0, 1 ); - } - - @Test - public void parallelCreatesCorrectReport() - { - unpack( "surefire-1122-parallel-and-flakyTests" ) - .activateProfile( "parallel" ) - .executeTest() - .assertTestSuiteResults( 2, 0, 0, 0, 1 ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java deleted file mode 100644 index f7324c9..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1135ImproveIgnoreMessageForTestNGIT.java +++ /dev/null @@ -1,152 +0,0 @@ -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 static org.apache.maven.shared.utils.xml.Xpp3DomBuilder.build; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; - -import java.io.FileNotFoundException; - -import org.apache.maven.shared.utils.xml.Xpp3Dom; -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; - -/** - * Test surefire-report on TestNG test - * - * @author <a href="mailto:michal.bo...@gmail.com">Michal Bocek</a> - */ -public class Surefire1135ImproveIgnoreMessageForTestNGIT - extends SurefireJUnit4IntegrationTestCase -{ - - private enum ResultType - { - SKIPPED( "skipped" ), FAILURE( "failure" ); - - private final String type; - - ResultType(String type) - { - this.type = type; - } - - public String getType() { - return type; - } - } - - @Test - public void testNgReport688() throws Exception { - testNgReport( "6.8.8", null, ResultType.SKIPPED, - "Skip test", - /*"org.testng.SkipException"*/ null, - /*"SkipExceptionReportTest.java:30"*/ null ); - } - - @Test - public void testNgReport57() throws Exception { - testNgReport( "5.7", "jdk15", ResultType.SKIPPED, - "Skip test", - /*"org.testng.SkipException"*/ null, - /*"SkipExceptionReportTest.java:30"*/ null ); - } - - private void testNgReport( String version, String classifier, ResultType resultType, String message, String type, - String stackTrace ) - throws Exception - { - OutputValidator outputValidator = - runTest( version, classifier, resultType, "/surefire-1135-improve-ignore-message-for-testng" ); - - Xpp3Dom[] children = readTests( outputValidator, "testng.SkipExceptionReportTest" ); - assertThat( "Report should contains only one test case", children.length, is( 1 ) ); - - Xpp3Dom test = children[0]; - assertThat( "Not expected classname", test.getAttribute( "classname" ), - is( "testng.SkipExceptionReportTest" ) ); - - assertThat( "Not expected test name", test.getAttribute( "name" ), is( "testSkipException" ) ); - - children = test.getChildren( resultType.getType() ); - assertThat( "Test should contains only one " + resultType.getType() + " element", children, - is( arrayWithSize( 1 ) ) ); - - Xpp3Dom result = children[0]; - if ( message == null ) - { - assertThat( "Subelement message attribute must be null", result.getAttribute( "message" ), - is( nullValue() ) ); - } - else - { - assertThat( "Subelement should contains message attribute", result.getAttribute( "message" ), - is( message ) ); - } - - if ( type == null ) - { - assertThat( "Subelement type attribute must be null", result.getAttribute( "type" ), is( nullValue() ) ); - } - else - { - assertThat( "Subelement should contains type attribute", result.getAttribute( "type" ), is( type ) ); - } - - if ( stackTrace == null ) - { - assertThat( "Element body must be null", result.getValue() , isEmptyOrNullString() ); - } - else - { - assertThat( "Element body must contains", result.getValue(), containsString( stackTrace ) ); - } - } - - private OutputValidator runTest( String version, String classifier, ResultType resultType, String resource ) - { - int skipped = ResultType.SKIPPED.equals( resultType ) ? 1 : 0; - int failure = ResultType.FAILURE.equals( resultType ) ? 1 : 0; - - SurefireLauncher launcher = unpack( resource ).sysProp( "testNgVersion", version ); - - if ( classifier != null ) - { - launcher.sysProp( "testNgClassifier", classifier ); - } - - return launcher.addSurefireReportGoal() - .executeCurrentGoals() - .assertTestSuiteResults( 1, 0, failure, skipped ); - } - - private static Xpp3Dom[] readTests( OutputValidator validator, String className ) - throws FileNotFoundException - { - Xpp3Dom testResult = - build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(), - "UTF-8" - ); - return testResult.getChildren( "testcase" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java deleted file mode 100644 index 8aaecea..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java +++ /dev/null @@ -1,43 +0,0 @@ -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-1136 Correct current working directory propagation in forked mode - * - * Note: variables expansion behaves differently on MVN 2.x since not existing variables - * are resolved to 'null' value so that ${surefire.forkNumber} cannot work. - * - * @author Norbert Wnuk - */ -public class Surefire1136CwdPropagationInForkedModeIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void testTestNgAndJUnitTogether() - { - OutputValidator outputValidator = unpack( "surefire-1136-cwd-propagation-in-forked-mode" ).executeTest(); - outputValidator.assertTestSuiteResults( 1, 0, 0, 0 ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java deleted file mode 100644 index d81d7c2..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1144XmlRunTimeIT.java +++ /dev/null @@ -1,58 +0,0 @@ -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.ReportTestSuite; -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.apache.maven.surefire.its.fixture.HelperAssertions.extractReports; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; - -/** - * Test that runtime reported on console matches runtime in XML - * - * @author <a href="mailto:elous...@illinois.edu">Lamyaa Eloussi</a> - */ -public class Surefire1144XmlRunTimeIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void testXmlRunTime() - throws Exception - { - OutputValidator outputValidator = unpack( "/surefire-1144-xml-runtime" ).forkOnce().executeTest(); - - List<ReportTestSuite> reports = extractReports( outputValidator.getBaseDir() ); - assertThat( reports, hasSize( 1 ) ); - - ReportTestSuite report = reports.get( 0 ); - float xmlTime = report.getTimeElapsed(); - - assertThat( xmlTime, is(greaterThanOrEqualTo( 1.6f ) ) ); //include beforeClass and afterClass - outputValidator.verifyTextInLog( Float.toString( xmlTime ) ); //same time in console - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java deleted file mode 100644 index f78c16a..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1146RerunFailedAndParameterized.java +++ /dev/null @@ -1,75 +0,0 @@ -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; - -/** - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1146">SUREFIRE-1146</a> - */ -public class Surefire1146RerunFailedAndParameterized - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void testsAreRerun() - { - OutputValidator outputValidator = unpack( "surefire-1146-rerunFailingTests-with-Parameterized" ).executeTest(); - verify(outputValidator, 8, 0, 0, 0, 5); - } - - private void verify( OutputValidator outputValidator, int run, int failures, int errors, int skipped, int flakes ) - { - outputValidator.verifyTextInLog( "Flakes:" ); - outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionParameterizedTest.flakyTest[0: (Test11); Test12; Test13;](jiras.surefire1146.CustomDescriptionParameterizedTest)" ); - outputValidator.verifyTextInLog( "Run 1: CustomDescriptionParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 2: CustomDescriptionParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 3: PASS" ); - - outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest.flakyTest[0: (Test11), Test12, Test13;](jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest)" ); - outputValidator.verifyTextInLog( "Run 1: CustomDescriptionWithCommaParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 2: CustomDescriptionWithCommaParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 3: PASS" ); - - outputValidator.verifyTextInLog( "jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest.flakyTest[2: (Test31), Test32, Test33;](jiras.surefire1146.CustomDescriptionWithCommaParameterizedTest)" ); - outputValidator.verifyTextInLog( "Run 1: CustomDescriptionWithCommaParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 2: PASS" ); - - outputValidator.verifyTextInLog( "jiras.surefire1146.SimpleParameterizedTest.flakyTest[0](jiras.surefire1146.SimpleParameterizedTest)" ); - outputValidator.verifyTextInLog( "Run 1: SimpleParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 2: SimpleParameterizedTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 3: PASS" ); - - outputValidator.verifyTextInLog( "jiras.surefire1146.StandardTest.flakyTest(jiras.surefire1146.StandardTest)" ); - outputValidator.verifyTextInLog( "Run 1: StandardTest.flakyTest:" ); - outputValidator.verifyTextInLog( "Run 2: PASS" ); - - verifyStatistics( outputValidator, run, failures, errors, skipped, flakes ); - } - - private void verifyStatistics( OutputValidator outputValidator, int run, int failures, int errors, int skipped, - int flakes ) - { - outputValidator.verifyTextInLog( "Tests run: " + run + ", Failures: " + failures + ", Errors: " + errors - + ", Skipped: " + skipped + ", Flakes: " + flakes ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java deleted file mode 100644 index 58e951a..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java +++ /dev/null @@ -1,64 +0,0 @@ -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-1152 Assert rerunFailingTestsCount works with test suites - * - * @author Sean Flanigan - */ -public class Surefire1152RerunFailingTestsInSuiteIT - extends SurefireJUnit4IntegrationTestCase -{ - private static final String RUNNING_WITH_PROVIDER47 = - "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider"; - - public OutputValidator runMethodPattern( String projectName, String... goals ) - { - SurefireLauncher launcher = unpack( projectName ); - for ( String goal : goals ) - { - launcher.addGoal( goal ); - } - OutputValidator outputValidator = launcher.showErrorStackTraces().debugLogging().executeVerify(); - outputValidator.assertTestSuiteResults( 3, 0, 0, 0, 3 ); - outputValidator.assertIntegrationTestSuiteResults( 1, 0, 0, 0 ); - return outputValidator; - } - - @Test - public void testJUnit48Provider4() - { - runMethodPattern( "surefire-1152-rerunFailingTestsCount-suite", "-P surefire-junit4" ); - } - - @Test - public void testJUnit48Provider47() - { - runMethodPattern( "surefire-1152-rerunFailingTestsCount-suite", "-P surefire-junit47" ) - .verifyTextInLog( RUNNING_WITH_PROVIDER47 ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java deleted file mode 100644 index 3a2c826..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java +++ /dev/null @@ -1,46 +0,0 @@ -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; - -public class Surefire1153IncludesAndSpecifiedTestIT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void testSpecifiedTestInIncludes() - { - unpack( "/surefire-1153-includesAndSpecifiedTest" ) - .setTestToRun( "#testIncluded" ) - .executeTest() - .verifyErrorFree( 1 ); - } - - @Test - public void testSpecifiedTestNotInIncludes() - { - unpack( "/surefire-1153-includesAndSpecifiedTest" ) - .setTestToRun( "#testNotIncluded" ) - .executeTest() - .verifyErrorFree( 1 ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java deleted file mode 100644 index 706f6b5..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java +++ /dev/null @@ -1,142 +0,0 @@ -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.SurefireVerifierException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.ArrayList; - -import static org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase.unpack; -import static org.junit.runners.Parameterized.*; -import static org.junit.Assert.*; - -/** - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1158">SUREFIRE-1158</a> - * @since 2.19 - */ -@RunWith( Parameterized.class ) -public class Surefire1158RemoveInfoLinesIT -{ - - @Parameters(name = "{0}") - public static Iterable<Object[]> data() - { - ArrayList<Object[]> args = new ArrayList<Object[]>(); - args.add( new Object[] { "junit-option-ff", "JUnitTest", "-ff", "surefire-junit47", false, true } ); - args.add( new Object[] { "testng-option-ff", "TestNGSuiteTest", "-ff", "surefire-testng", false, false } ); - args.add( new Object[] { "junit-option-X", "JUnitTest", "-X", "surefire-junit47", true, true } ); - args.add( new Object[] { "testng-option-X", "TestNGSuiteTest", "-X", "surefire-testng", true, false } ); - args.add( new Object[] { "junit-option-e", "JUnitTest", "-e", "surefire-junit47", true, true } ); - args.add( new Object[] { "testng-option-e", "TestNGSuiteTest", "-e", "surefire-testng", true, false } ); - return args; - } - - @Parameter(0) - public String description; - - @Parameter(1) - public String testToRun; - - @Parameter(2) - public String cliOption; - - @Parameter(3) - public String provider; - - @Parameter(4) - public boolean printsInfoLines; - - @Parameter(5) - public boolean isJUnit; - - @Test - public void shouldRunWithCliOption() - throws Exception - { - OutputValidator validator = assertTest(); - if ( isJUnit ) - { - assertJUnitTestLogs( validator ); - } - else - { - assertTestNGTestLogs( validator ); - } - } - - private OutputValidator assertTest() - throws Exception - { - final String[] cli = {"--batch-mode"}; - return unpack( getClass(), "/surefire-1158-remove-info-lines", "_" + description, cli ) - .sysProp( "provider", provider ).addGoal( cliOption ).setTestToRun( testToRun ) - .executeTest() - .verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 ); - } - - private void assertJUnitTestLogs( OutputValidator validator ) - { - try - { - validator.verifyTextInLog( "Surefire report directory:" ); - validator.verifyTextInLog( "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider" ); - validator.verifyTextInLog( "parallel='none', perCoreThreadCount=true, threadCount=0, " - + "useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, " - + "threadCountMethods=0, parallelOptimized=true" ); - if ( !printsInfoLines ) - { - fail(); - } - } - catch ( SurefireVerifierException e ) - { - if ( printsInfoLines ) - { - fail(); - } - } - } - - private void assertTestNGTestLogs( OutputValidator validator ) - { - try - { - validator.verifyTextInLog( "Surefire report directory:" ); - validator.verifyTextInLog( "Using configured provider org.apache.maven.surefire.testng.TestNGProvider" ); - validator.verifyTextInLog( "Configuring TestNG with: TestNGMapConfigurator" ); - if ( !printsInfoLines ) - { - fail(); - } - } - catch ( SurefireVerifierException e ) - { - if ( printsInfoLines ) - { - fail(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java deleted file mode 100644 index 8c2c213..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java +++ /dev/null @@ -1,59 +0,0 @@ -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; - -import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; - -/** - * IT for https://issues.apache.org/jira/browse/SUREFIRE-1177 - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @since 2.19 - */ -public class Surefire1177TestngParallelSuitesIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void shouldRunTwoSuitesInParallel() - throws VerificationException - { - assumeJavaVersion( 1.7d ); - - unpack().executeTest() - .verifyErrorFree( 2 ) - .assertThatLogLine( containsString( "ShouldNotRunTest#shouldNotRun()" ), is( 0 ) ) - .assertThatLogLine( startsWith( "TestNGSuiteTest#shouldRunAndPrintItself()" ), is( 2 ) ) - .assertThatLogLine( is( "TestNGSuiteTest#shouldRunAndPrintItself() 1." ), is( 1 ) ) - .assertThatLogLine( is( "TestNGSuiteTest#shouldRunAndPrintItself() 2." ), is( 1 ) ); - } - - private SurefireLauncher unpack() - { - return unpack( "testng-parallel-suites" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java deleted file mode 100644 index e4e8e31..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1179IT.java +++ /dev/null @@ -1,43 +0,0 @@ -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; - -/** - * Fix for TestNG parameter -dataproviderthreadcount. - */ -public class Surefire1179IT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void suiteXmlForkCountTwoReuse() - { - unpack().executeTest().verifyErrorFreeLog().verifyTextInLog( " CONCURRENCY=30." ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1179-testng-parallel-dataprovider" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java deleted file mode 100644 index 74a4e46..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; - -/** - * Surefire 2.19 spawns unnecessary tests in surefire-junit4 provider. - * https://issues.apache.org/jira/browse/SUREFIRE-1185 - * Example, UnlistedTest is the problem here because it runs with filtered out methods: - * - * Running pkg.UnlistedTest - * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in pkg.UnlistedTest - * Running pkg.RunningTest - * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in pkg.RunningTest - * - * Results: - * - * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - */ -public class Surefire1185DoNotSpawnTestsIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void doNotSpawnUnwantedTests() - throws VerificationException - { - unpack().setTestToRun( "RunningTest#test" ) - .executeTest() - .assertTestSuiteResults( 1 ) - .assertThatLogLine( containsString( "in pkg.RunningTest" ), is( 1 ) ) - .assertThatLogLine( containsString( "in pkg.UnlistedTest" ), is( 0 ) ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1185" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java deleted file mode 100644 index f886446..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java +++ /dev/null @@ -1,58 +0,0 @@ -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; - -/** - * Allow rerunFailingTestsCount, skipAfterFailureCount together - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1202">SUREFIRE-1202</a> - * @since 2.19.1 - */ -public class Surefire1202RerunAndSkipIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void junit47() - throws VerificationException - { - unpack().executeTest() - .assertTestSuiteResults( 5, 0, 0, 3, 4 ); - } - - @Test - public void junit4() - throws VerificationException - { - unpack().addGoal( "-Pjunit4" ) - .executeTest() - .assertTestSuiteResults( 5, 0, 0, 3, 4 ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1202-rerun-and-failfast" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java deleted file mode 100644 index 6ee87fb..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java +++ /dev/null @@ -1,75 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java deleted file mode 100644 index 53cd764..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java +++ /dev/null @@ -1,62 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java deleted file mode 100644 index c4031c2..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1260NewTestsPattern.java +++ /dev/null @@ -1,49 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java deleted file mode 100644 index bd9af17..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1264IT.java +++ /dev/null @@ -1,58 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java deleted file mode 100644 index 2e92805..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1265Java9IT.java +++ /dev/null @@ -1,57 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java deleted file mode 100644 index c0b0339..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1278GroupNameEndingIT.java +++ /dev/null @@ -1,44 +0,0 @@ -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/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java deleted file mode 100644 index 3ca758a..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java +++ /dev/null @@ -1,125 +0,0 @@ -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:'." ); - } - } - } - - } - - -}