[SUREFIRE-1041] Created integration test based on sample project provided by 
Dan Fabulich


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/56972416
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/56972416
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/56972416

Branch: refs/heads/master
Commit: 569724167048c945c9b316547536ec96bae97806
Parents: ec46baf
Author: Andreas Gudian <agud...@apache.org>
Authored: Sat Mar 8 20:54:36 2014 +0100
Committer: Andreas Gudian <agud...@apache.org>
Committed: Sun Mar 9 20:18:58 2014 +0100

----------------------------------------------------------------------
 .../jiras/Surefire1041FailingJUnitRunnerIT.java | 38 +++++++++++++
 .../pom.xml                                     | 60 ++++++++++++++++++++
 .../src/test/java/test/AppTest.java             | 38 +++++++++++++
 .../src/test/java/test/BadRunner.java           | 43 ++++++++++++++
 4 files changed, 179 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/56972416/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java
new file mode 100644
index 0000000..bb65682
--- /dev/null
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java
@@ -0,0 +1,38 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+/**
+ * SUREFIRE-1041: An error in a JUnit runner should not lead to an error in 
Surefire
+ *
+ * @author Andreas Gudian
+ */
+public class Surefire1041FailingJUnitRunnerIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void reportErrorInJUnitRunnerAsTestError()
+    {
+        unpack( "surefire-1041-exception-in-junit-runner" 
).mavenTestFailureIgnore( true ).executeTest().assertTestSuiteResults( 1, 1, 0, 
0 );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/56972416/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml
 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml
new file mode 100644
index 0000000..e1331cb
--- /dev/null
+++ 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/pom.xml
@@ -0,0 +1,60 @@
+<?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>surefire-1041</artifactId>
+  <name>Tests that test reporter does not fail with NPE when a JUnit-Runner 
has an error.</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>once</forkMode>
+          <forkCount>1</forkCount>
+        </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.surefire</groupId>
+            <artifactId>surefire-junit47</artifactId>
+            <version>${surefire.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/56972416/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/AppTest.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/AppTest.java
 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/AppTest.java
new file mode 100644
index 0000000..978da1a
--- /dev/null
+++ 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/AppTest.java
@@ -0,0 +1,38 @@
+package test;
+
+/*
+ * 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;
+import org.junit.runner.RunWith;
+
+/**
+ *
+ * @author Dan Fabulich
+ *
+ */
+@RunWith(BadRunner.class)
+public class AppTest
+{
+
+    @Test
+    public void testApp()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/56972416/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/BadRunner.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/BadRunner.java
 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/BadRunner.java
new file mode 100644
index 0000000..759c0f4
--- /dev/null
+++ 
b/surefire-integration-tests/src/test/resources/surefire-1041-exception-in-junit-runner/src/test/java/test/BadRunner.java
@@ -0,0 +1,43 @@
+package test;
+
+/*
+ * 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.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+/**
+ *
+ * @author Dan Fabulich
+ *
+ */
+public class BadRunner extends BlockJUnit4ClassRunner{
+
+       public BadRunner(Class<?> testClass) throws InitializationError {
+               super(testClass);
+       }
+
+       @Override
+       public void run(RunNotifier notifier) {
+               String x = null;
+               if (false) x = "";
+               x.toString();
+       }
+}

Reply via email to