Updated Branches: refs/heads/master 25724d17c -> 0a2ae0750
[SUREFIRE-1019] add IT to test executing JUnit4 tests together with TestNG tests using the surefire-testng provider Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/0a2ae075 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/0a2ae075 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/0a2ae075 Branch: refs/heads/master Commit: 0a2ae0750ee91ad7476f0ff50fffb759b94f1f64 Parents: 25724d1 Author: Andreas Gudian <agud...@apache.org> Authored: Fri Jul 26 20:51:50 2013 +0200 Committer: Andreas Gudian <agud...@apache.org> Committed: Fri Jul 26 20:51:50 2013 +0200 ---------------------------------------------------------------------- .../Surefire377TestNgAndJUnitTogetherIT.java | 6 ++ .../resources/testng-junit4-together/pom.xml | 63 ++++++++++++++++++++ .../src/test/java/Junit4NoRunWithTest.java | 53 ++++++++++++++++ .../src/test/java/Junit4SimpleRunWithTest.java | 56 +++++++++++++++++ .../src/test/java/TestNGTest.java | 50 ++++++++++++++++ 5 files changed, 228 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0a2ae075/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java index ea0a5df..2fe4ff0 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire377TestNgAndJUnitTogetherIT.java @@ -35,4 +35,10 @@ public class Surefire377TestNgAndJUnitTogetherIT { executeErrorFreeTest( "/testng-junit-together", 2 ); } + + @Test + public void testTestNgAndJUnit4Together() + { + executeErrorFreeTest( "/testng-junit4-together", 3 ); + } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0a2ae075/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml b/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml new file mode 100644 index 0000000..d7700a4 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/testng-junit4-together/pom.xml @@ -0,0 +1,63 @@ +<?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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>it-parent</artifactId> + <version>1.0</version> + </parent> + + <artifactId>testng-junit4-together</artifactId> + <version>1.0-SNAPSHOT</version> + <name>TestNG and Junit4 Together</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.8.5</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0a2ae075/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4NoRunWithTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4NoRunWithTest.java b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4NoRunWithTest.java new file mode 100644 index 0000000..8641825 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4NoRunWithTest.java @@ -0,0 +1,53 @@ +/* + * 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.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +/** + * Provided to ensure both junit and testng tests can run together. + * + * @author jkuhnert + * @author agudian + */ +public class Junit4NoRunWithTest { + + Object testObject; + + /** + * Creats an object instance + */ + @Before + public void setUp() + { + testObject = new Object(); + } + + /** + * Tests that object created in setup + * isn't null. + */ + @Test + public void isJunitObject() + { + assertNotNull(testObject); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0a2ae075/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4SimpleRunWithTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4SimpleRunWithTest.java b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4SimpleRunWithTest.java new file mode 100644 index 0000000..38f9215 --- /dev/null +++ b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/Junit4SimpleRunWithTest.java @@ -0,0 +1,56 @@ +/* + * 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.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Provided to ensure both junit and testng tests can run together. + * + * @author jkuhnert + * @author agudian + */ +@RunWith(JUnit4.class) +public class Junit4SimpleRunWithTest { + + Object testObject; + + /** + * Creats an object instance + */ + @Before + public void setUp() + { + testObject = new Object(); + } + + /** + * Tests that object created in setup + * isn't null. + */ + @Test + public void isJunitObject() + { + assertNotNull(testObject); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0a2ae075/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/TestNGTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/TestNGTest.java b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/TestNGTest.java new file mode 100644 index 0000000..a7edb4a --- /dev/null +++ b/surefire-integration-tests/src/test/resources/testng-junit4-together/src/test/java/TestNGTest.java @@ -0,0 +1,50 @@ +/* + * 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.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +/** + * Simple test + * + * @author jkuhnert + */ +public class TestNGTest { + + /** + * Sets up testObject + */ + @BeforeClass + public void configureTest() + { + testObject = new Object(); + } + + Object testObject; + + /** + * Tests reporting an error + */ + @Test + public void testNGTest() + { + assert testObject != null : "testObject is null"; + } +}