http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test1.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test1.java b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test1.java new file mode 100644 index 0000000..d206283 --- /dev/null +++ b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test1.java @@ -0,0 +1,60 @@ +package junit4.forkMode; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.management.ManagementFactory; + +import org.junit.Test; + +public class Test1 +{ + + @Test + public void test1() + throws IOException + { + dumpPidFile( "test1" ); + } + + public static void dumpPidFile( String name ) + throws IOException + { + String fileName = name + "-pid"; + File target = new File( "target" ); + if ( !( target.exists() && target.isDirectory() ) ) + { + target = new File( "." ); + } + File pidFile = new File( target, fileName ); + FileWriter fw = new FileWriter( pidFile ); + // DGF little known trick... this is guaranteed to be unique to the PID + // In fact, it usually contains the pid and the local host name! + String pid = ManagementFactory.getRuntimeMXBean().getName(); + fw.write( pid ); + fw.flush(); + fw.close(); + + System.out.println( "pid = " + pid ); + } + +}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test2.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test2.java b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test2.java new file mode 100644 index 0000000..f57f1b8 --- /dev/null +++ b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test2.java @@ -0,0 +1,36 @@ +package junit4.forkMode; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +import org.junit.Test; + +public class Test2 +{ + + @Test + public void test2() + throws IOException + { + Test1.dumpPidFile( "test2" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test3.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test3.java b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test3.java new file mode 100644 index 0000000..af7f6fd --- /dev/null +++ b/surefire-its/src/test/resources/junit-fork-mode-always/src/test/java/junit4/forkMode/Test3.java @@ -0,0 +1,36 @@ +package junit4.forkMode; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +import org.junit.Test; + +public class Test3 +{ + + @Test + public void test3() + throws IOException + { + Test1.dumpPidFile( "test3" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-ignore/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-ignore/pom.xml b/surefire-its/src/test/resources/junit-ignore/pom.xml new file mode 100644 index 0000000..d9c3817 --- /dev/null +++ b/surefire-its/src/test/resources/junit-ignore/pom.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-ignore</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test of @Ignore annotation</name> + + <properties> + <junit.version>4.4</junit.version> + <surefire.parallel></surefire.parallel> + <surefire.threadcount>3</surefire.threadcount> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <parallel>${surefire.parallel}</parallel> + <perCoreThreadCount>false</perCoreThreadCount> + <threadCount>${surefire.threadcount}</threadCount> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java new file mode 100644 index 0000000..66e858e --- /dev/null +++ b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassAndMethodIgnoreNothingToRunTest.java @@ -0,0 +1,37 @@ +package junit.ignore; + +/* + * 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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore( "ignore this test" ) +public class ClassAndMethodIgnoreNothingToRunTest +{ + + @Ignore( "ignore this test" ) + @Test + public void testIgnorable() + { + Assert.fail( "you should have ignored me!" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java new file mode 100644 index 0000000..7012f87 --- /dev/null +++ b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore1WithMethodThatIsNormalTest.java @@ -0,0 +1,36 @@ +package junit.ignore; + +/* + * 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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore( "ignore this test" ) +public class ClassLevelIgnore1WithMethodThatIsNormalTest +{ + + @Test + public void testIgnorable() + { + Assert.fail( "you should have ignored me!" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java new file mode 100644 index 0000000..ee64317 --- /dev/null +++ b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/ClassLevelIgnore2WithMethodThatIsNormalTest.java @@ -0,0 +1,36 @@ +package junit.ignore; + +/* + * 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.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore( "ignore this test" ) +public class ClassLevelIgnore2WithMethodThatIsNormalTest +{ + + @Test + public void testIgnorable() + { + Assert.fail( "you should have ignored me!" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java new file mode 100644 index 0000000..cc50d1d --- /dev/null +++ b/surefire-its/src/test/resources/junit-ignore/src/test/java/junit/ignore/NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest.java @@ -0,0 +1,57 @@ +package junit.ignore; + +/* + * 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.junit.Assume; +import org.junit.Ignore; +import org.junit.Test; + +/** + * @author Kristian Rosenvold + */ +public class NormalClassWithThreeIgnoredMethodsAnd1AssumptionFailureTest +{ + + @Ignore + @Test + public void testWithIgnore1() + { + } + + @Ignore("Ignorance is bliss2") + @Test + public void testWithIgnore2() + { + } + + @Ignore("Ignorance \"is\' <>bliss2") + @Test + public void testWithQuotesInIgnore() + { + } + + @Test + public void testWithAssumptionFailure() + { + Assume.assumeNotNull( new Object[]{ null} ); + } + +} + http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-innerClass/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-innerClass/pom.xml b/surefire-its/src/test/resources/junit-innerClass/pom.xml new file mode 100644 index 0000000..fb1ffd6 --- /dev/null +++ b/surefire-its/src/test/resources/junit-innerClass/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-innerClass</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test JUnit classes with inner classes</name> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-innerClass/src/test/java/junit/innerClass/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-innerClass/src/test/java/junit/innerClass/BasicTest.java b/surefire-its/src/test/resources/junit-innerClass/src/test/java/junit/innerClass/BasicTest.java new file mode 100644 index 0000000..81be27e --- /dev/null +++ b/surefire-its/src/test/resources/junit-innerClass/src/test/java/junit/innerClass/BasicTest.java @@ -0,0 +1,39 @@ +package junit.innerClass; + +/* + * 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 junit.framework.TestCase; + +public class BasicTest + extends TestCase +{ + + public void testFoo() + { + new Foo( "x", "y" ); + } + + public class Foo + { + public Foo( String x, String y ) + { + } + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml b/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml new file mode 100644 index 0000000..8a95201 --- /dev/null +++ b/surefire-its/src/test/resources/junit-notExtendingTestCase/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-notExtendingTestCase</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for JUnit tests that don't extend TestCase</name> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/SuiteTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/SuiteTest.java b/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/SuiteTest.java new file mode 100644 index 0000000..69fa59a --- /dev/null +++ b/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/SuiteTest.java @@ -0,0 +1,49 @@ +package junit.notExtendingTestCase; + +/* + * 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 junit.framework.Test; +import junit.framework.TestResult; +import junit.framework.TestSuite; + + +public class SuiteTest + extends TestSuite +{ + public static Test suite() { + SuiteTest suite = new SuiteTest(); + suite.addTest( new Test() { + + public int countTestCases() + { + return 1; + } + + public void run( TestResult result ) + { + result.startTest( this ); + result.endTest( this ); + + } + + } ); + return suite; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/TestHelper.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/TestHelper.java b/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/TestHelper.java new file mode 100644 index 0000000..1065dca --- /dev/null +++ b/surefire-its/src/test/resources/junit-notExtendingTestCase/src/test/java/junit/notExtendingTestCase/TestHelper.java @@ -0,0 +1,24 @@ +package junit.notExtendingTestCase; + +/* + * 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. + */ + +public class TestHelper { + public TestHelper(String two, String arguments) {} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml b/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml new file mode 100644 index 0000000..890839e --- /dev/null +++ b/surefire-its/src/test/resources/junit-pathWithUmlaut/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-path-with-umlaut</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test path with Ãmlaut</name> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-pathWithUmlaut/src/test/java/umlautTest/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-pathWithUmlaut/src/test/java/umlautTest/BasicTest.java b/surefire-its/src/test/resources/junit-pathWithUmlaut/src/test/java/umlautTest/BasicTest.java new file mode 100644 index 0000000..0c27bb5 --- /dev/null +++ b/surefire-its/src/test/resources/junit-pathWithUmlaut/src/test/java/umlautTest/BasicTest.java @@ -0,0 +1,87 @@ +package umlautTest; + + +/* + * 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 junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class BasicTest + extends TestCase +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + public BasicTest( String name, String extraName ) + { + super( name ); + } + + public static Test suite() + { + TestSuite suite = new TestSuite(); + Test test = new BasicTest( "testSetUp", "dummy" ); + suite.addTest( test ); + + return new TestSetup( suite ) + { + + protected void setUp() + { + //oneTimeSetUp(); + } + + protected void tearDown() + { + oneTimeTearDown(); + } + + }; + } + + protected void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + protected void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + public void testSetUp() + { + assertTrue( "setUp was not called", setUpCalled ); + } + + public static void oneTimeTearDown() + { + assertTrue( "tearDown was not called", tearDownCalled ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml b/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml new file mode 100644 index 0000000..f2075ae --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCaseSuite/pom.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-twoTestCaseSuite</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for single suite with two test cases</name> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <includes> + <include>**/WrapperTestSuite.java</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java new file mode 100644 index 0000000..bc0d2c7 --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/BasicTest.java @@ -0,0 +1,86 @@ +package junit.twoTestCaseSuite; + + +/* + * 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 junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class BasicTest + extends TestCase +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + public BasicTest( String name, String extraName ) + { + super( name ); + } + + public static Test suite() + { + TestSuite suite = new TestSuite(); + Test test = new BasicTest( "testSetUp", "dummy" ); + suite.addTest( test ); + + return new TestSetup( suite ) + { + + protected void setUp() + { + //oneTimeSetUp(); + } + + protected void tearDown() + { + oneTimeTearDown(); + } + + }; + } + + protected void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + protected void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + public void testSetUp() + { + assertTrue( "setUp was not called", setUpCalled ); + } + + public static void oneTimeTearDown() + { + assertTrue( "tearDown was not called", tearDownCalled ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java new file mode 100644 index 0000000..f403819 --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/TestTwo.java @@ -0,0 +1,29 @@ +package junit.twoTestCaseSuite; + +/* + * 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 junit.framework.TestCase; + + +public class TestTwo + extends TestCase +{ + public void testTwo() {} +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java new file mode 100644 index 0000000..9bd71b5 --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCaseSuite/src/test/java/junit/twoTestCaseSuite/WrapperTestSuite.java @@ -0,0 +1,40 @@ +package junit.twoTestCaseSuite; + + +/* + * 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 junit.framework.Test; +import junit.framework.TestSuite; + +public class WrapperTestSuite + extends TestSuite +{ + public WrapperTestSuite( String name ) + { + super( name ); + } + + public static Test suite() { + WrapperTestSuite suite = new WrapperTestSuite( "My Acceptance Test Suite" ); + suite.addTestSuite( TestTwo.class ); + suite.addTest( BasicTest.suite() ); + return suite; + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCases/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCases/pom.xml b/surefire-its/src/test/resources/junit-twoTestCases/pom.xml new file mode 100644 index 0000000..89684ad --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCases/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit-twoTestCases</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for two test cases</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/BasicTest.java b/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/BasicTest.java new file mode 100644 index 0000000..2efc5ed --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/BasicTest.java @@ -0,0 +1,86 @@ +package junit.twoTestCases; + +/* + * 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 junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class BasicTest + extends TestCase +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + public BasicTest( String name ) + { + super( name ); + } + + public static Test suite() + { + TestSuite suite = new TestSuite(); + Test test = new BasicTest( "testSetUp" ); + suite.addTest( test ); + + return new TestSetup( suite ) + { + + protected void setUp() + { + //oneTimeSetUp(); + } + + protected void tearDown() + { + oneTimeTearDown(); + } + + }; + } + + protected void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + protected void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + public void testSetUp() + { + assertTrue( "setUp was not called", setUpCalled ); + } + + public static void oneTimeTearDown() + { + assertTrue( "tearDown was not called", tearDownCalled ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/TestTwo.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/TestTwo.java b/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/TestTwo.java new file mode 100644 index 0000000..9af4558 --- /dev/null +++ b/surefire-its/src/test/resources/junit-twoTestCases/src/test/java/junit/twoTestCases/TestTwo.java @@ -0,0 +1,29 @@ +package junit.twoTestCases; + +/* + * 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 junit.framework.TestCase; + + +public class TestTwo + extends TestCase +{ + public void testTwo() {} +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml new file mode 100644 index 0000000..4bfc081 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/pom.xml @@ -0,0 +1,38 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.surefire.test</groupId> + <artifactId>junit4-forkAlways-staticInit</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>JUnit4 ForkAlways StaticInit Pollution</name> + <description> + Test that static initializers on classes other than the one being executed in the current test-set will not be run, and cannot pollute the environment. + </description> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <forkMode>always</forkMode> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/App2Test.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/App2Test.java b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/App2Test.java new file mode 100644 index 0000000..90f56d4 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/App2Test.java @@ -0,0 +1,50 @@ +package junit4; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import junit.framework.TestCase; + +/** + * Unit test for simple App. + */ +public class App2Test + extends TestCase +{ + + static + { + System.out.println( "Loading " + App2Test.class.getName() ); + + Properties p = System.getProperties(); + p.setProperty( "Foo", "Bar2" ); + System.setProperties( p ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + System.out.println( "Expecting: Bar2\nGot: " + System.getProperty( "Foo" ) ); + assertEquals( "Expecting: Bar2\nGot: " + System.getProperty( "Foo" ), "Bar2", System.getProperty( "Foo" ) ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/AppTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/AppTest.java b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/AppTest.java new file mode 100644 index 0000000..4b2b0d7 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-forkAlways-staticInit/src/test/java/junit4/AppTest.java @@ -0,0 +1,50 @@ +package junit4; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import junit.framework.TestCase; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + + static + { + System.out.println( "Loading " + AppTest.class.getName() ); + + Properties p = System.getProperties(); + p.setProperty( "Foo", "Bar" ); + System.setProperties( p ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + System.out.println( "Expecting: Bar\nGot: " + System.getProperty( "Foo" ) ); + assertEquals( "Expecting: Bar\nGot: " + System.getProperty( "Foo" ), "Bar", System.getProperty( "Foo" ) ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-rerun-failing-tests/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-rerun-failing-tests/pom.xml b/surefire-its/src/test/resources/junit4-rerun-failing-tests/pom.xml new file mode 100644 index 0000000..9456a29 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-rerun-failing-tests/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit4-rerun-failing-tests</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for rerun failing tests in JUnit 4</name> + + <properties> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/FlakyFirstTimeTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/FlakyFirstTimeTest.java b/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/FlakyFirstTimeTest.java new file mode 100644 index 0000000..264462c --- /dev/null +++ b/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/FlakyFirstTimeTest.java @@ -0,0 +1,62 @@ +package junit4; + +/* + * 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.junit.Assert; +import org.junit.Test; + + +public class FlakyFirstTimeTest +{ + private static int failingCount = 0; + + private static int errorCount = 0; + + + @Test + public void testFailingTestOne() + { + System.out.println( "Failing test" ); + // This test will fail with only one retry, but will pass with two + if ( failingCount < 2 ) + { + failingCount++; + Assert.fail( "Failing test" ); + } + } + + @Test + public void testErrorTestOne() throws Exception + { + System.out.println( "Error test" ); + // This test will error out with only one retry, but will pass with two + if ( errorCount < 2 ) + { + errorCount++; + throw new IllegalArgumentException("..."); + } + } + + @Test + public void testPassingTest() throws Exception + { + System.out.println( "Passing test" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/PassingTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/PassingTest.java b/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/PassingTest.java new file mode 100644 index 0000000..7cb0b57 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-rerun-failing-tests/src/test/java/junit4/PassingTest.java @@ -0,0 +1,39 @@ +package junit4; + +/* + * 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.junit.Assert; +import org.junit.Test; + + +public class PassingTest +{ + @Test + public void testPassingTestOne() + { + System.out.println( "Passing test one" ); + } + + @Test + public void testPassingTestTwo() throws Exception + { + System.out.println( "Passing test two" ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/pom.xml b/surefire-its/src/test/resources/junit4-runlistener/pom.xml new file mode 100644 index 0000000..d776533 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/pom.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit4-runlistener</artifactId> + <version>1.0-SNAPSHOT</version> + <name>JUnit4 RunListener test</name> + + <properties> + <junitVersion>4.4</junitVersion> + <provider>surefire-junit4</provider> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junitVersion}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <properties> + <property> + <name>listener</name> + <value>runListener.FileWritingRunListener1,runListener.FileWritingRunListener2,runListener.EchoingRunListener</value> + </property> + </properties> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>${provider}</artifactId> + <version>${surefire.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java new file mode 100644 index 0000000..305c656 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/EchoingRunListener.java @@ -0,0 +1,82 @@ +package runListener; + +/* + * 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.junit.runner.Description; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; + +/** + * {@link org.junit.runner.notification.RunListener} to generate an output file whose existence can be checked by surefire-integration. + * + * @author <a href="mailto:matthew.gilli...@gmail.com">Matthew Gilliard</a> + */ +public class EchoingRunListener + extends RunListener +{ + + @Override + public void testRunStarted( Description description ) + throws Exception + { + System.out.println("testRunStarted " + description); + } + + @Override + public void testRunFinished( Result result ) + throws Exception + { + System.out.println("testRunFinished " + result); + } + + @Override + public void testStarted( Description description ) + throws Exception + { + System.out.println("testStarted " + description); + } + + @Override + public void testFinished( Description description ) + throws Exception + { + System.out.println("testFinished " + description); + } + + @Override + public void testFailure( Failure failure ) + throws Exception + { + System.out.println("testFailure " + failure); + } + + @Override + public void testIgnored( Description description ) + throws Exception + { + System.out.println("testIgnored " + description); + } + + public void testAssumptionFailure( Failure failure ) + { + System.out.println("testAssumptionFailure " + failure); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java new file mode 100644 index 0000000..85d0a5b --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileHelper.java @@ -0,0 +1,44 @@ +package runListener; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +public class FileHelper +{ + public static void writeFile( String fileName, String content ) + { + try + { + File target = new File( "target" ).getAbsoluteFile(); + File listenerOutput = new File( target, fileName ); + FileWriter out = new FileWriter( listenerOutput ); + out.write( content ); + out.flush(); + out.close(); + } + catch ( IOException e ) + { + throw new RuntimeException( e ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener1.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener1.java b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener1.java new file mode 100644 index 0000000..24f479d --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener1.java @@ -0,0 +1,40 @@ +package runListener; + +/* + * 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.junit.runner.Description; +import org.junit.runner.notification.RunListener; + +/** + * {@link RunListener} to generate an output file whose existence can be checked by surefire-integration. + * + * @author <a href="mailto:matthew.gilli...@gmail.com">Matthew Gilliard</a> + */ +public class FileWritingRunListener1 + extends RunListener +{ + + @Override + public void testStarted( Description description ) + { + FileHelper.writeFile( "runlistener-output-1.txt", "This written by RunListener#testStarted()" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener2.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener2.java b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener2.java new file mode 100644 index 0000000..49c2824 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/FileWritingRunListener2.java @@ -0,0 +1,40 @@ +package runListener; + +/* + * 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.junit.runner.Description; +import org.junit.runner.notification.RunListener; + +/** + * {@link RunListener} to generate an output file whose existence can be checked by surefire-integration. + * + * @author <a href="mailto:matthew.gilli...@gmail.com">Matthew Gilliard</a> + */ +public class FileWritingRunListener2 + extends RunListener +{ + + @Override + public void testStarted( Description description ) + { + FileHelper.writeFile( "runlistener-output-2.txt", "This written by RunListener#testStarted()" ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/JUnit4RunListenerTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/JUnit4RunListenerTest.java b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/JUnit4RunListenerTest.java new file mode 100644 index 0000000..12c32ac --- /dev/null +++ b/surefire-its/src/test/resources/junit4-runlistener/src/test/java/runListener/JUnit4RunListenerTest.java @@ -0,0 +1,32 @@ +package runListener; + +/* + * 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.junit.Assert; +import org.junit.Test; + +public class JUnit4RunListenerTest { + + @Test + public void simpleTest() + { + Assert.assertEquals( 2, 1 + 1 ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml new file mode 100644 index 0000000..867cd09 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/pom.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit4-twoTestCaseSuite</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for JUnit 4 suite with two test cases</name> + + + <properties> + <junitVersion>4.4</junitVersion> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junitVersion}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <includes> + <include>**/Junit4TestSuite.java</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java new file mode 100644 index 0000000..a793610 --- /dev/null +++ b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/BasicTest.java @@ -0,0 +1,64 @@ +package twoTestCaseSuite; + +/* + * 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.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class BasicTest +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + @Before + public void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + @After + public void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + @Test + public void testSetUp() + { + Assert.assertTrue( "setUp was not called", setUpCalled ); + } + + @AfterClass + public static void oneTimeTearDown() + { + + } + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java new file mode 100644 index 0000000..011c70e --- /dev/null +++ b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestSuite.java @@ -0,0 +1,33 @@ +package twoTestCaseSuite; + +/* + * 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.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + BasicTest.class, + Junit4TestTwo.class +}) +public class Junit4TestSuite +{ + +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java new file mode 100644 index 0000000..849e64b --- /dev/null +++ b/surefire-its/src/test/resources/junit4-twoTestCaseSuite/src/test/java/twoTestCaseSuite/Junit4TestTwo.java @@ -0,0 +1,27 @@ +package twoTestCaseSuite; + +/* + * 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.junit.Test; + +public class Junit4TestTwo +{ + @Test public void secondTest() {} +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4/pom.xml b/surefire-its/src/test/resources/junit4/pom.xml new file mode 100644 index 0000000..bba9b00 --- /dev/null +++ b/surefire-its/src/test/resources/junit4/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>junit4</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for JUnit 4</name> + + <properties> + <junitVersion>4.4</junitVersion> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/09f0eef8/surefire-its/src/test/resources/junit4/src/test/java/junit4/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/junit4/src/test/java/junit4/BasicTest.java b/surefire-its/src/test/resources/junit4/src/test/java/junit4/BasicTest.java new file mode 100644 index 0000000..e9234f2 --- /dev/null +++ b/surefire-its/src/test/resources/junit4/src/test/java/junit4/BasicTest.java @@ -0,0 +1,65 @@ +package junit4; + +/* + * 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.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class BasicTest +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + @Before + public void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + @After + public void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + @Test + public void testSetUp() + { + Assert.assertTrue( "setUp was not called", setUpCalled ); + } + + + @AfterClass + public static void oneTimeTearDown() + { + + } + +}