http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java new file mode 100644 index 0000000..6aac330 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputIT.java @@ -0,0 +1,87 @@ +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; + +/** + * Asserts proper behaviour of console output when forking + * SUREFIRE-639 + * SUREFIRE-651 + * + * @author Kristian Rosenvold + */ +public class ForkConsoleOutputIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void printSummaryTrueWithRedirect() + { + unpack().setForkJvm() + .redirectToFile( true ) + .printSummary( true ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileExists(); + } + + @Test + public void printSummaryTrueWithoutRedirect() + { + unpack().setForkJvm() + .redirectToFile( false ) + .printSummary( true ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileNotExists(); + } + + @Test + public void printSummaryFalseWithRedirect() + { + unpack().setForkJvm() + .redirectToFile( true ) + .printSummary( false ) + .debugLogging() + .showErrorStackTraces() + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileExists(); + } + + @Test + public void printSummaryFalseWithoutRedirect() + { + unpack().setForkJvm() + .redirectToFile( false ) + .printSummary( false ) + .executeTest() + .getSurefireReportsFile( "forkConsoleOutput.Test1-output.txt" ) + .assertFileNotExists(); + } + + + private SurefireLauncher unpack() + { + return unpack( "/fork-consoleOutput" ); + } +}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java new file mode 100644 index 0000000..e5feb7f --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.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; + +/** + * Asserts proper behaviour of console output when forking + * SUREFIRE-639 + * SUREFIRE-651 + * + * @author Kristian Rosenvold + */ +public class ForkConsoleOutputWithErrorsIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void xmlFileContainsConsoleOutput() + { + unpack( "/fork-consoleOutputWithErrors" ) + .setForkJvm() + .failNever() + .redirectToFile( true ) + .executeTest() + .getSurefireReportsXmlFile( "TEST-forkConsoleOutput.Test2.xml" ) + .assertContainsText( "sout: Will Fail soon" ) + .assertContainsText( "serr: Will Fail now" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java new file mode 100644 index 0000000..574d144 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java @@ -0,0 +1,241 @@ +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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +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.junit.BeforeClass; +import org.junit.Test; + +/** + * Test forkMode + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class ForkModeIT + extends SurefireJUnit4IntegrationTestCase +{ + + private OutputValidator outputValidator; + + @BeforeClass + public static void installDumpPidPlugin() + throws Exception + { + unpack( ForkModeIT.class, "test-helper-dump-pid-plugin", "plugin" ).executeInstall(); + } + + @Test + public void testForkModeAlways() + { + String[] pids = doTest( unpack( getProject() ).setForkJvm().forkAlways() ); + assertDifferentPids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkModePerTest() + { + String[] pids = doTest( unpack( getProject() ).setForkJvm().forkPerTest() ); + assertDifferentPids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkModeNever() + { + String[] pids = doTest( unpack( getProject() ).forkNever() ); + assertSamePids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] ); + } + + @Test + public void testForkModeNone() + { + String[] pids = doTest( unpack( getProject() ).forkMode( "none" ) ); + assertSamePids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] ); + } + + @Test + public void testForkModeOncePerThreadSingleThread() + { + String[] pids = doTest( unpack( getProject() ) + .setForkJvm() + .forkPerThread() + .reuseForks( true ) + .threadCount( 1 ) ); + assertSamePids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkModeOncePerThreadTwoThreads() + { + String[] pids = doTest( unpack( getProject() ) + .forkPerThread() + .reuseForks( true ) + .threadCount( 2 ) + .addGoal( "-DsleepLength=1200" ) ); + assertDifferentPids( pids, 2 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkCountZero() + { + String[] pids = doTest( unpack( getProject() ).forkCount( 0 ) ); + assertSamePids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] ); + } + + @Test + public void testForkCountOneNoReuse() + { + String[] pids = doTest( unpack( getProject() ).setForkJvm().forkCount( 1 ).reuseForks( false ) ); + assertDifferentPids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkCountOneReuse() + { + String[] pids = doTest( unpack( getProject() ).setForkJvm().forkCount( 1 ).reuseForks( true ) ); + assertSamePids( pids ); + assertEndWith( pids, "_1_1", 3 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkCountTwoNoReuse() + { + String[] pids = + doTest( unpack( getProject() ).setForkJvm().forkCount( 2 ).reuseForks( false ).addGoal( "-DsleepLength=1200" ) ); + assertDifferentPids( pids ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + @Test + public void testForkCountTwoReuse() + { + String[] pids = + doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( true ).addGoal( "-DsleepLength=1200" ) ); + assertDifferentPids( pids, 2 ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + private void assertEndWith( String[] pids, String suffix, int expectedMatches ) + { + int matches = 0; + for ( String pid : pids ) + { + if ( pid.endsWith( suffix ) ) + { + matches++; + } + } + + assertEquals( "suffix " + suffix + " matched the correct number of pids", expectedMatches, matches ); + } + + private void assertDifferentPids( String[] pids, int numOfDifferentPids ) + { + Set<String> pidSet = new HashSet<String>( Arrays.asList( pids ) ); + assertEquals( "number of different pids is not as expected", numOfDifferentPids, pidSet.size() ); + } + + @Test + public void testForkModeOnce() + { + String[] pids = doTest( unpack( getProject() ).forkOnce() ); + assertSamePids( pids ); + assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) ); + } + + private String getMainPID() + { + final TestFile targetFile = outputValidator.getTargetFile( "maven.pid" ); + String pid = targetFile.slurpFile(); + return pid + " testValue_1_1"; + } + + private void assertSamePids( String[] pids ) + { + assertEquals( "pid 1 didn't match pid 2", pids[0], pids[1] ); + assertEquals( "pid 1 didn't match pid 3", pids[0], pids[2] ); + } + + private void assertDifferentPids( String[] pids ) + { + if ( pids[0].equals( pids[1] ) ) + { + fail( "pid 1 matched pid 2: " + pids[0] ); + } + + if ( pids[0].equals( pids[2] ) ) + { + fail( "pid 1 matched pid 3: " + pids[0] ); + } + + if ( pids[1].equals( pids[2] ) ) + { + fail( "pid 2 matched pid 3: " + pids[0] ); + } + } + + private String[] doTest( SurefireLauncher forkMode ) + { + forkMode.sysProp( "testProperty", "testValue_${surefire.threadNumber}_${surefire.forkNumber}" ); + forkMode.addGoal( "org.apache.maven.plugins.surefire:maven-dump-pid-plugin:dump-pid" ); + outputValidator = forkMode.executeTest(); + outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 ); + String[] pids = new String[3]; + for ( int i = 1; i <= pids.length; i++ ) + { + final TestFile targetFile = outputValidator.getTargetFile( "test" + i + "-pid" ); + String pid = targetFile.slurpFile(); + pids[i - 1] = pid; + } + return pids; + } + + protected String getProject() + { + return "fork-mode"; + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeMultiModuleIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeMultiModuleIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeMultiModuleIT.java new file mode 100644 index 0000000..22588cc --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeMultiModuleIT.java @@ -0,0 +1,162 @@ +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 java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Test forkMode in a multi module project with parallel maven builds + * + * @author Andreas Gudian + */ +public class ForkModeMultiModuleIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testForkCountOneNoReuse() + { + List<String> pids = doTest( unpack( getProject() ).forkCount( 1 ).reuseForks( false ) ); + assertAllDifferentPids( pids ); + int matchesOne = countSuffixMatches( pids, "_1_1"); + int matchesTwo = countSuffixMatches( pids, "_2_2" ); + assertTrue( "At least one fork had forkNumber 1", matchesOne >= 1 ); + assertTrue( "At least one fork had forkNumber 2", matchesTwo >= 1 ); + assertEquals( "No other forkNumbers than 1 and 2 have been used", 6, matchesOne + matchesTwo); + } + + + @Test + public void testForkCountOneReuse() + { + List<String> pids = doTest( unpack( getProject() ).forkCount( 1 ).reuseForks( true ) ); + assertDifferentPids( pids, 2 ); + assertEndWith( pids, "_1_1", 3 ); + assertEndWith( pids, "_2_2", 3 ); + } + + @Test + public void testForkCountTwoNoReuse() + { + List<String> pids = doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( false ) ); + assertAllDifferentPids( pids ); + int matchesOne = countSuffixMatches( pids, "_1_1"); + int matchesTwo = countSuffixMatches( pids, "_2_2" ); + int matchesThree = countSuffixMatches( pids, "_3_3"); + int matchesFour = countSuffixMatches( pids, "_4_4" ); + assertTrue( "At least one fork had forkNumber 1", matchesOne >= 1 ); + assertTrue( "At least one fork had forkNumber 2", matchesTwo >= 1 ); + assertTrue( "At least one fork had forkNumber 3", matchesThree >= 1 ); + assertTrue( "At least one fork had forkNumber 4", matchesFour >= 1 ); + assertEquals( "No other forkNumbers than 1, 2, 3, or 4 have been used", 6, matchesOne + matchesTwo + matchesThree + matchesFour ); + } + + @Test + public void testForkCountTwoReuse() + { + List<String> pids = + doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( true ) ); + assertDifferentPids( pids, 4 ); + + int matchesOne = countSuffixMatches( pids, "_1_1"); + int matchesTwo = countSuffixMatches( pids, "_2_2" ); + int matchesThree = countSuffixMatches( pids, "_3_3"); + int matchesFour = countSuffixMatches( pids, "_4_4" ); + assertTrue( "At least one fork had forkNumber 1", matchesOne >= 1 ); + assertTrue( "At least one fork had forkNumber 2", matchesTwo >= 1 ); + assertTrue( "At least one fork had forkNumber 3", matchesThree >= 1 ); + assertTrue( "At least one fork had forkNumber 4", matchesFour >= 1 ); + assertEquals( "No other forkNumbers than 1, 2, 3, or 4 have been used", 6, matchesOne + matchesTwo + matchesThree + matchesFour ); + } + + private void assertEndWith( List<String> pids, String suffix, int expectedMatches ) + { + int matches = countSuffixMatches( pids, suffix ); + + assertEquals( "suffix " + suffix + " matched the correct number of pids", expectedMatches, matches ); + } + + private int countSuffixMatches( List<String> pids, String suffix ) + { + int matches = 0; + for ( String pid : pids ) + { + if ( pid.endsWith( suffix ) ) + { + matches++; + } + } + return matches; + } + + private void assertDifferentPids( List<String> pids, int numOfDifferentPids ) + { + Set<String> pidSet = new HashSet<String>( pids ); + assertEquals( "number of different pids is not as expected", numOfDifferentPids, pidSet.size() ); + } + + private void assertAllDifferentPids( List<String> pids ) + { + assertDifferentPids( pids, pids.size() ); + } + + private List<String> doTest( SurefireLauncher forkMode ) + { + forkMode.addGoal( "-T2" ); + forkMode.sysProp( "testProperty", "testValue_${surefire.threadNumber}_${surefire.forkNumber}" ); + final OutputValidator outputValidator = forkMode.setForkJvm().executeTest(); + List<String> pids = new ArrayList<String>( 6 ); + pids.addAll( validateModule( outputValidator, "module-a" ) ); + pids.addAll( validateModule( outputValidator, "module-b" ) ); + + return pids; + } + + private List<String> validateModule( OutputValidator outputValidator, String module ) + { + HelperAssertions.assertTestSuiteResults( 3, 0, 0, 0, new File( outputValidator.getBaseDir(), module ) ); + + List<String> pids = new ArrayList<String>( 3 ); + for ( int i = 1; i <= 3; i++ ) + { + final TestFile targetFile = outputValidator.getTargetFile( module, "test" + i + "-pid" ); + String pid = targetFile.slurpFile(); + pids.add( pid ); + } + + return pids; + } + + protected String getProject() + { + return "fork-mode-multimodule"; + } + + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java new file mode 100644 index 0000000..5ba0577 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java @@ -0,0 +1,35 @@ +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. + */ + +/** + * Test forkMode + * + * @author <a href="mailto:velo...@gmail.com">Marvin Froeder</a> + */ +public class ForkModeTestNGIT + extends ForkModeIT +{ + @Override + protected String getProject() + { + return "fork-mode-testng"; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java new file mode 100644 index 0000000..a6c539c --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesFromFileIT.java @@ -0,0 +1,95 @@ +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.SurefireLauncher; +import org.junit.Test; + +/** + * Test include/exclude from files. + * <br> + * Based on {@link IncludesExcludesIT}. + */ +public class IncludesExcludesFromFileIT + extends SurefireJUnit4IntegrationTestCase +{ + private SurefireLauncher unpack() + { + return unpack( "/includes-excludes-from-file" ); + } + + @Test + public void testSimple() + { + testWithProfile( "simple" ); + } + + @Test + public void testSimpleMixed() + { + testWithProfile( "simple-mixed" ); + } + + @Test + public void testRegex() + { + testWithProfile( "regex" ); + } + + @Test + public void testPath() + { + testWithProfile( "path" ); + } + + @Test + public void testMissingExcludes() + { + expectBuildFailure("missing-excludes-file", "Failed to load list from file", "no-such-excludes-file"); + } + + @Test + public void testMissingIncludes() + { + expectBuildFailure( "missing-includes-file", "Failed to load list from file", "no-such-includes-file" ); + } + + private void testWithProfile( String profile ) + { + final OutputValidator outputValidator = unpack(). + activateProfile( profile ).executeTest().verifyErrorFree( 2 ); + + outputValidator.getTargetFile( "testTouchFile.txt" ).assertFileExists(); + outputValidator.getTargetFile( "defaultTestTouchFile.txt" ).assertFileExists(); + } + + private void expectBuildFailure( final String profile, final String... messages ) + { + final OutputValidator outputValidator = unpack().activateProfile( profile ) + .maven().withFailure().executeTest(); + + for ( String message : messages ) + { + outputValidator.verifyTextInLog( message ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java new file mode 100644 index 0000000..46bdeb6 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/IncludesExcludesIT.java @@ -0,0 +1,68 @@ +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.SurefireLauncher; +import org.junit.Test; + +/** + * Test include/exclude patterns. + * + * @author Benjamin Bentmann + */ +public class IncludesExcludesIT + extends SurefireJUnit4IntegrationTestCase +{ + private SurefireLauncher unpack() + { + return unpack( "/includes-excludes" ); + } + + /** + * Test surefire inclusions/exclusions + */ + @Test + public void testIncludesExcludes() + { + testWithProfile( "simple" ); + } + + @Test + public void testRegexIncludesExcludes() + { + testWithProfile( "regex" ); + } + + @Test + public void testPathBasedIncludesExcludes() + { + testWithProfile( "path" ); + } + + private void testWithProfile( String profile ) + { + final OutputValidator outputValidator = unpack(). + activateProfile( profile ).executeTest().verifyErrorFree( 2 ); + outputValidator.getTargetFile( "testTouchFile.txt" ).assertFileExists(); + outputValidator.getTargetFile( "defaultTestTouchFile.txt" ).assertFileExists(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.java new file mode 100644 index 0000000..7bf90f0 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit44HamcrestIT.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 project using JUnit4.4 (including Hamcrest extensions) + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class JUnit44HamcrestIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testJUnit44Hamcrest() + { + executeErrorFreeTest( "junit44-hamcrest", 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java new file mode 100644 index 0000000..57007a7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.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.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; + +/** + * Basic suite test using all known versions of JUnit 4.x + * + * @author Kristian Rosenvold + */ +public class JUnit47ConcurrencyIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void test47() + throws Exception + { + OutputValidator validator = unpack( "junit47-concurrency" ) + .executeTest() + .verifyErrorFree( 4 ); + String result = null; + for ( String line : validator.loadLogLines() ) + { + if ( line.startsWith( "[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:" ) ) + { + result = line; + break; + } + } + assertNotNull( result); + assertThat( result, anyOf( containsString( "Time elapsed: 1." ), containsString( "Time elapsed: 0.9" ) ) ); + assertThat( result, endsWith( " s - in concurrentjunit47.src.test.java.junit47.BasicTest" ) ); + } +} \ 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/JUnit47ParallelIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java new file mode 100644 index 0000000..5aee1a8 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java @@ -0,0 +1,540 @@ +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; + +/** + * Testing JUnitCoreWrapper with ParallelComputerBuilder. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.16 + */ +public class JUnit47ParallelIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void unknownThreadCountSuites() + { + unpack().parallelSuites().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use threadCount or threadCountSuites > 0 or useUnlimitedThreads=true for parallel='suites'" ); + } + + @Test + public void unknownThreadCountClasses() + { + unpack().parallelClasses().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use threadCount or threadCountClasses > 0 or useUnlimitedThreads=true for parallel='classes'" ); + } + + @Test + public void unknownThreadCountMethods() + { + unpack().parallelMethods().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use threadCount or threadCountMethods > 0 or useUnlimitedThreads=true for parallel='methods'" ); + + } + + @Test + public void unknownThreadCountBoth() + { + unpack().parallelBoth().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use useUnlimitedThreads=true, " + + "or only threadCount > 0, " + + "or (threadCountClasses > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountClasses > 0 and threadCount > threadCountClasses) " + + "for parallel='both' or parallel='classesAndMethods'" ); + } + + @Test + public void unknownThreadCountAll() + { + unpack().parallelAll().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use useUnlimitedThreads=true, " + + "or only threadCount > 0, " + + "or (threadCountSuites > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + + "or every thread-count is specified, " + + "or (threadCount > 0 and threadCountSuites > 0 and threadCountClasses > 0 " + + "and threadCount > threadCountSuites + threadCountClasses) " + + "for parallel='all'" ); + } + + @Test + public void unknownThreadCountSuitesAndClasses() + { + unpack().parallelSuitesAndClasses().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use useUnlimitedThreads=true, " + + "or only threadCount > 0, " + + "or (threadCountSuites > 0 and threadCountClasses > 0), " + + "or (threadCount > 0 and threadCountSuites > 0 and threadCountClasses > 0) " + + "or (threadCount > 0 and threadCountSuites > 0 and threadCount > threadCountSuites) " + + "for parallel='suitesAndClasses' or 'both'" ); + } + + @Test + public void unknownThreadCountSuitesAndMethods() + { + unpack().parallelSuitesAndMethods().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use useUnlimitedThreads=true, " + + "or only threadCount > 0, " + + "or (threadCountSuites > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountSuites > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountSuites > 0 and threadCount > threadCountSuites) " + + "for parallel='suitesAndMethods'" ); + } + + @Test + public void unknownThreadCountClassesAndMethods() + { + unpack().parallelClassesAndMethods().setTestToRun( "TestClass" ).failNever().executeTest().verifyTextInLog( + "Use useUnlimitedThreads=true, " + + "or only threadCount > 0, " + + "or (threadCountClasses > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountClasses > 0 and threadCountMethods > 0), " + + "or (threadCount > 0 and threadCountClasses > 0 and threadCount > threadCountClasses) " + + "for parallel='both' or parallel='classesAndMethods'" ); + } + + @Test + public void serial() + { + // takes 7.2 sec + unpack().setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsSuites1() + { + // takes 3.6 sec + unpack().parallelSuites().useUnlimitedThreads().setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void unlimitedThreadsSuites2() + { + // takes 3.6 sec + unpack().parallelSuites().useUnlimitedThreads().threadCountSuites( 5 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsClasses1() + { + // takes 1.8 sec + unpack().parallelClasses().useUnlimitedThreads().setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void unlimitedThreadsClasses2() + { + // takes 1.8 sec + unpack().parallelClasses().useUnlimitedThreads().threadCountClasses( 5 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsMethods1() + { + // takes 2.4 sec + unpack().parallelMethods().useUnlimitedThreads().setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void unlimitedThreadsMethods2() + { + // takes 2.4 sec + unpack().parallelMethods().useUnlimitedThreads().threadCountMethods( 5 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsSuitesAndClasses1() + { + // takes 0.9 sec + unpack().parallelSuitesAndClasses().useUnlimitedThreads().setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsSuitesAndClasses2() + { + // takes 0.9 sec + // 1.8 sec with 4 parallel classes + unpack().parallelSuitesAndClasses().useUnlimitedThreads().threadCountSuites( 5 ).threadCountClasses( + 15 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsSuitesAndMethods1() + { + // takes 1.2 sec + unpack().parallelSuitesAndMethods().useUnlimitedThreads().setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsSuitesAndMethods2() + { + // takes 1.2 sec + unpack().parallelSuitesAndMethods().useUnlimitedThreads().threadCountSuites( 5 ).threadCountMethods( + 15 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsClassesAndMethods1() + { + // takes 0.6 sec + unpack().parallelClassesAndMethods().useUnlimitedThreads().setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsClassesAndMethods2() + { + // takes 0.6 sec + unpack().parallelClassesAndMethods().useUnlimitedThreads().threadCountClasses( 5 ).threadCountMethods( + 15 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsAll1() + { + // takes 0.3 sec + unpack().parallelAll().useUnlimitedThreads().setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void unlimitedThreadsAll2() + { + // takes 0.3 sec + unpack().parallelAll().useUnlimitedThreads().threadCountSuites( 5 ).threadCountClasses( 15 ).threadCountMethods( + 30 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountSuites() + { + // takes 3.6 sec + unpack().parallelSuites().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountClasses() + { + // takes 3.6 sec for single core + // takes 1.8 sec for double core + unpack().parallelClasses().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountMethods() + { + // takes 2.4 sec + unpack().parallelMethods().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountClassesAndMethodsOneCore() + { + // takes 4.8 sec + unpack().disablePerCoreThreadCount().disableParallelOptimization().parallelClassesAndMethods().threadCount( + 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountClassesAndMethodsOneCoreOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().disablePerCoreThreadCount().parallelClassesAndMethods().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountClassesAndMethods() + { + // takes 2.4 sec for double core CPU + unpack().disableParallelOptimization().parallelClassesAndMethods().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountClassesAndMethodsOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelClassesAndMethods().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountSuitesAndMethods() + { + // usually 24 times 0.3 sec = 7.2 sec with one core CPU + // takes 1.8 sec for double core CPU + unpack().disableParallelOptimization().parallelSuitesAndMethods().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountSuitesAndMethodsOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelSuitesAndMethods().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void threadCountSuitesAndClasses() + { + unpack().disableParallelOptimization().parallelSuitesAndClasses().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountSuitesAndClassesOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelSuitesAndClasses().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void threadCountAll() + { + unpack().disableParallelOptimization().parallelAll().threadCount( 3 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void threadCountAllOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelAll().threadCount( 3 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void everyThreadCountSuitesAndClasses() + { + // takes 1.8 sec for double core CPU + unpack().parallelSuitesAndClasses().threadCount( 3 ).threadCountSuites( 34 ).threadCountClasses( + 66 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void everyThreadCountSuitesAndMethods() + { + // takes 1.8 sec for double core CPU + unpack().parallelSuitesAndMethods().threadCount( 3 ).threadCountSuites( 34 ).threadCountMethods( + 66 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void everyThreadCountClassesAndMethods() + { + // takes 1.8 sec for double core CPU + unpack().parallelClassesAndMethods().threadCount( 3 ).threadCountClasses( 34 ).threadCountMethods( + 66 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void everyThreadCountAll() + { + // takes 2.4 sec for double core CPU + unpack().parallelAll().threadCount( 3 ).threadCountSuites( 17 ).threadCountClasses( 34 ).threadCountMethods( + 49 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountSuitesAndClasses() + { + // 4 * cpu to 5 * cpu threads to run test classes + // takes cca 1.8 sec + unpack().disableParallelOptimization().parallelSuitesAndClasses().disablePerCoreThreadCount().threadCount( + 6 ).threadCountSuites( 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountSuitesAndClassesOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelSuitesAndClasses().disablePerCoreThreadCount().threadCount( 6 ).threadCountSuites( + 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountSuitesAndMethods() + { + // 4 * cpu to 5 * cpu threads to run test methods + // takes cca 1.8 sec + unpack().disableParallelOptimization().parallelSuitesAndMethods().disablePerCoreThreadCount().threadCount( + 6 ).threadCountSuites( 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountSuitesAndMethodsOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelSuitesAndMethods().disablePerCoreThreadCount().threadCount( 6 ).threadCountSuites( + 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountClassesAndMethods() + { + // 4 * cpu to 5 * cpu threads to run test methods + // takes cca 1.8 sec + unpack().disableParallelOptimization().parallelClassesAndMethods().disablePerCoreThreadCount().threadCount( + 6 ).threadCountClasses( 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountClassesAndMethodsOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelClassesAndMethods().disablePerCoreThreadCount().threadCount( 6 ).threadCountClasses( + 2 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountAll() + { + // 8 * cpu to 13 * cpu threads to run test methods + // takes 0.9 sec + unpack().disableParallelOptimization().parallelAll().disablePerCoreThreadCount().threadCount( + 14 ).threadCountSuites( 2 ).threadCountClasses( 4 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void reusableThreadCountAllOptimized() + { + // the number of reused threads in leafs depends on the number of runners and CPU + unpack().parallelAll().disablePerCoreThreadCount().threadCount( 14 ).threadCountSuites( 2 ).threadCountClasses( + 4 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void suites() + { + // takes 3.6 sec + unpack().parallelSuites().threadCountSuites( 5 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void classes() + { + // takes 1.8 sec on any CPU because the suites are running in a sequence + unpack().parallelClasses().threadCountClasses( 5 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void methods() + { + // takes 2.4 sec on any CPU because every class has only three methods + // and the suites and classes are running in a sequence + unpack().parallelMethods().threadCountMethods( 5 ).setTestToRun( "Suite*Test" ).executeTest().verifyErrorFree( + 24 ); + } + + @Test + public void suitesAndClasses() + { + // takes 0.9 sec + unpack().parallelSuitesAndClasses().threadCountSuites( 5 ).threadCountClasses( 15 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void suitesAndMethods() + { + // takes 1.2 sec on any CPU + unpack().parallelSuitesAndMethods().threadCountSuites( 5 ).threadCountMethods( 15 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void classesAndMethods() + { + // takes 0.6 sec on any CPU + unpack().parallelClassesAndMethods().threadCountClasses( 5 ).threadCountMethods( 15 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void all() + { + // takes 0.3 sec on any CPU + unpack().parallelAll().threadCountSuites( 5 ).threadCountClasses( 15 ).threadCountMethods( 30 ).setTestToRun( + "Suite*Test" ).executeTest().verifyErrorFree( 24 ); + } + + @Test + public void shutdown() + { + // executes for 2.5 sec until timeout has elapsed + unpack().parallelMethods().threadCountMethods( 2 ).parallelTestsTimeoutInSeconds( 2.5d ).setTestToRun( + "TestClass" ).failNever().executeTest().verifyTextInLog( + "The test run has finished abruptly after timeout of 2.5 seconds." ); + } + + @Test + public void forcedShutdown() + { + // executes for 2.5 sec until timeout has elapsed + unpack().parallelMethods().threadCountMethods( 2 ).parallelTestsTimeoutForcedInSeconds( 2.5d ).setTestToRun( + "TestClass" ).failNever().executeTest().verifyTextInLog( + "The test run has finished abruptly after timeout of 2.5 seconds." ); + } + + @Test + public void timeoutAndForcedShutdown() + { + // executes for one sec until timeout has elapsed + unpack().parallelMethods().threadCountMethods( 2 ).parallelTestsTimeoutInSeconds( + 1 ).parallelTestsTimeoutForcedInSeconds( 2.5d ).setTestToRun( + "TestClass" ).failNever().executeTest().verifyTextInLog( + "The test run has finished abruptly after timeout of 1.0 seconds." ); + } + + @Test + public void forcedShutdownVerifyingLogs() + { + // executes for 2.5 sec until timeout has elapsed + unpack().parallelMethods().threadCountMethods( 3 ).disablePerCoreThreadCount() + .parallelTestsTimeoutForcedInSeconds( 1.05d ).setTestToRun( "Waiting*Test" ).failNever().executeTest() + .verifyTextInLog( "The test run has finished abruptly after timeout of 1.05 seconds." ) + .verifyTextInLog( "These tests were executed in prior to the shutdown operation:" ) + .verifyTextInLog( "These tests are incomplete:" ); + } + + private SurefireLauncher unpack() + { + return unpack( "junit47-parallel" ) + .showErrorStackTraces(); + } +} \ 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/JUnit47ParallelNotThreadSafeIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java new file mode 100644 index 0000000..bf393ca --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelNotThreadSafeIT.java @@ -0,0 +1,52 @@ +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; + +/** + * Testing {@code @net.jcip.annotations.NotThreadSafe} with ParallelComputerBuilder. + * + * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> + * @since 2.19 + */ +public class JUnit47ParallelNotThreadSafeIT + extends SurefireJUnit4IntegrationTestCase +{ + + private SurefireLauncher unpack() + { + return unpack( "junit47-parallel-nts" ); + } + + @Test + public void test() + { + unpack() + .parallelAll() + .useUnlimitedThreads() + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "xxx-maven-surefire-plugin@NotThreadSafe" ) + .verifyTextInLog( "expected-thread" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java new file mode 100644 index 0000000..aa38dac --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java @@ -0,0 +1,71 @@ +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.commons.lang.StringUtils; +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.io.IOException; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +public class JUnit47RedirectOutputIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testPrintSummaryTrueWithRedirect() + throws Exception + { + final OutputValidator clean = unpack().redirectToFile( true ).addGoal( "clean" ).executeTest(); + checkReports( clean ); + } + + @Test + public void testClassesParallel() + throws Exception + { + final OutputValidator clean = + unpack().redirectToFile( true ).parallelClasses().addGoal( "clean" ).executeTest(); + checkReports( clean ); + } + + private void checkReports( OutputValidator validator ) + throws IOException + { + String report = StringUtils.trimToNull( + validator.getSurefireReportsFile( "junit47ConsoleOutput.Test1-output.txt" ).readFileToString() ); + assertNotNull( report ); + String report2 = StringUtils.trimToNull( + validator.getSurefireReportsFile( "junit47ConsoleOutput.Test2-output.txt" ).readFileToString() ); + assertNotNull( report2 ); + assertFalse( validator.getSurefireReportsFile( "junit47ConsoleOutput.Test3-output.txt" ).exists() ); + } + + + private SurefireLauncher unpack() + { + return unpack( "/junit47-redirect-output" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java new file mode 100644 index 0000000..9fe1775 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47RerunFailingTestWithCucumberIT.java @@ -0,0 +1,80 @@ +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 static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests using the JUnit 47 provider to rerun failing tests with the cucumber runner. The main + * problem that the junit4 provider has with the cucumber runner is that the junit Description + * instance created by the runner has a null test class attribute. This requires that tests are + * rerun based on their description. + * + * @author mpkorstanje + */ +public class JUnit47RerunFailingTestWithCucumberIT + extends SurefireJUnit4IntegrationTestCase { + + @Before + public void assumeJdk17() { + assumeJavaVersion(1.7d); + } + + + private SurefireLauncher unpack() { + return unpack("junit47-rerun-failing-tests-with-cucumber") + .setJUnitVersion("4.12"); + } + + @Test + public void testRerunFailingErrorTestsFalse() { + unpack() + .maven() + .addGoal("-Dsurefire.rerunFailingTestsCount=" + 0) + .withFailure() + .executeTest() + .assertTestSuiteResults(1, 0, 1, 0, 0); + } + + @Test + public void testRerunFailingErrorTestsWithOneRetry() { + unpack() + .maven() + .addGoal("-Dsurefire.rerunFailingTestsCount=" + 1) + .withFailure() + .executeTest() + .assertTestSuiteResults(1, 0, 1, 0, 0); + } + + @Test + public void testRerunFailingErrorTestsTwoRetry() { + unpack() + .maven() + .addGoal("-Dsurefire.rerunFailingTestsCount=" + 2) + .executeTest() + .assertTestSuiteResults(1, 0, 0, 0, 2); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.java new file mode 100644 index 0000000..e50e6d7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47StaticInnerClassTestsIT.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.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +public class JUnit47StaticInnerClassTestsIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Test + public void testStaticInnerClassTests() + { + executeErrorFreeTest( "junit47-static-inner-class-tests", 3 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.java new file mode 100644 index 0000000..38c2eae --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47WithCucumberIT.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.SurefireJUnit4IntegrationTestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; + +/** + * Tests the JUnit 47 provider with the cucumber runner. At the moment, they don't play along that perfectly (minor + * glitches in the reports with parallel=classes), but at least all tests are executed, the execution times are counted + * correctly and failing tests are reported. The main problem that the junit47 provider has with the cucumber runner is + * that the junit Description instance created by the runner has a null test class attribute. + * + * @author agudian + */ +public class JUnit47WithCucumberIT + extends SurefireJUnit4IntegrationTestCase +{ + + @Before + public void assumeJdk16() + { + assumeJavaVersion( 1.6d ); + } + + @Test + public void testWithoutParallel() + { + // 8 tests in total is what's probably correct + doTest( "none", 8 ); + } + + @Test + public void testWithParallelClasses() + { + // with parallel=classes, we get 9 tests in total, + // as the dummy "scenario" test entry is reported twice: once as success, and once with the failure from the + // failing test step + doTest( "classes", 9 ); + } + + private void doTest( String parallel, int total ) + { + unpack( "junit47-cucumber" ) + .sysProp( "parallel", parallel ) + .sysProp( "threadCount", "2" ) + .executeTest() + .assertTestSuiteResults( total, 0, 2, 0 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java new file mode 100644 index 0000000..fdb56f7 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java @@ -0,0 +1,145 @@ +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 project using "groups" support + * + * @author <a href="mailto:t...@apache.org">Todd Lipcon</a> + * @author <a href="mailto:krosenv...@apache.org">Kristian Rosenvold</a> + */ +public class JUnit48TestCategoriesIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testCategoriesAB() + { + runAB( unpacked() ); + } + + @Test + public void testCategoriesABForkAlways() + { + runAB( unpacked().forkAlways() ); + } + + @Test + public void testCategoriesACFullyQualifiedClassName() + { + runACFullyQualifiedClassName( unpacked() ); + } + + @Test + public void testCategoriesACFullyQualifiedClassNameForkAlways() + { + runACFullyQualifiedClassName( unpacked().forkAlways() ); + } + + @Test + public void testCategoriesACClassNameSuffix() + { + runACClassNameSuffix( unpacked() ); + } + + @Test + public void testCategoriesACClassNameSuffixForkAlways() + { + runACClassNameSuffix( unpacked().forkAlways() ); + } + + @Test + public void testCategoriesBadCategory() + { + runBadCategory( unpacked() ); + } + + @Test + public void testBadCategoryForkAlways() + { + runBadCategory( unpacked().forkAlways() ); + } + + private static void runAB( SurefireLauncher unpacked ) + { + unpacked.executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 3, 0, 0, 0 ) + .verifyTextInLog( "catA: 1" ) + .verifyTextInLog( "catB: 1" ) + .verifyTextInLog( "catC: 0" ) + .verifyTextInLog( "catNone: 0" ); + } + + private static void runACClassNameSuffix( SurefireLauncher unpacked ) + { + unpacked.groups( "CategoryA,CategoryC" ) + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 6, 0, 0, 0 ) + .verifyTextInLog( "catA: 1" ) + .verifyTextInLog( "catB: 0" ) + .verifyTextInLog( "catC: 1" ) + .verifyTextInLog( "catNone: 0" ) + .verifyTextInLog( "mA: 1" ) + + // This seems questionable !? The class is annotated with category C and method with B + .verifyTextInLog( "mB: 1" ) + + .verifyTextInLog( "mC: 1" ) + .verifyTextInLog( "CatNone: 1" ); + } + + private static void runACFullyQualifiedClassName( SurefireLauncher unpacked ) + { + unpacked.groups( "junit4.CategoryA,junit4.CategoryC" ) + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 6, 0, 0, 0 ) + .verifyTextInLog( "catA: 1" ) + .verifyTextInLog( "catB: 0" ) + .verifyTextInLog( "catC: 1" ) + .verifyTextInLog( "catNone: 0" ) + .verifyTextInLog( "mA: 1" ) + + // This seems questionable !? The class is annotated with category C and method with B + .verifyTextInLog( "mB: 1" ) + + .verifyTextInLog( "mC: 1" ) + .verifyTextInLog( "CatNone: 1" ); + } + + private static void runBadCategory( SurefireLauncher unpacked ) + { + unpacked.failIfNoTests( false ) + .groups( "BadCategory" ) + .executeTest() + .verifyErrorFreeLog(); + } + + private SurefireLauncher unpacked() + { + return unpack( "/junit48-categories" ); + // .debugSurefireFork(); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.java new file mode 100644 index 0000000..19b937d --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4ForkAlwaysStaticInitPollutionIT.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 JUnit 4 tests marked with "Ignore" attribute + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class JUnit4ForkAlwaysStaticInitPollutionIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testJunit4Ignore() + { + executeErrorFreeTest( "junit4-forkAlways-staticInit", 2 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java new file mode 100644 index 0000000..71ec3d8 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit4IgnoreIT.java @@ -0,0 +1,52 @@ +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 JUnit 4 tests marked with "Ignore" attribute + * + * @author <a href="mailto:dfabul...@apache.org">Dan Fabulich</a> + */ +public class JUnit4IgnoreIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testJunit4Ignore() + { + // Todo: Support assumption failure == ignore for junit4 + unpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 7, 0, 0, 6 ); + } + + @Test + public void testJunit47ParallelIgnore() + { + unpack().setJUnitVersion( "4.8.1" ).parallelClasses().executeTest().verifyErrorFreeLog().assertTestSuiteResults( + 7, 0, 0, 7 ); + } + + private SurefireLauncher unpack() + { + return unpack( "/junit-ignore" ); + } +}