You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2013/04/05 20:40:23 UTC
git commit: [SUREFIRE-972] Bizarre NoClassDef found errro
Updated Branches:
refs/heads/master 912258350 -> 01a3d7f65
[SUREFIRE-972] Bizarre NoClassDef found errro
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/01a3d7f6
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/01a3d7f6
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/01a3d7f6
Branch: refs/heads/master
Commit: 01a3d7f6518faba42071e0954206c95055f94b19
Parents: 9122583
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Fri Apr 5 20:39:42 2013 +0200
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Fri Apr 5 20:39:42 2013 +0200
----------------------------------------------------------------------
.../its/jiras/Surefire972BizarreNoClassDefIT.java | 32 +++++++++
.../surefire-972-bizarre-noclassdef/boom/pom.xml | 51 +++++++++++++++
.../org/apache/maven/surefire/crb/ClassRuleIT.java | 24 +++++++
.../class-rule/pom.xml | 17 +++++
.../ExampleClassRule.java | 29 ++++++++
.../surefire-972-bizarre-noclassdef/pom.xml | 32 +++++++++
.../surefire/common/junit4/JUnit4RunListener.java | 32 ++++++++-
7 files changed, 213 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java
new file mode 100644
index 0000000..94db9f8
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire972BizarreNoClassDefIT.java
@@ -0,0 +1,32 @@
+package org.apache.maven.surefire.its.jiras;
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.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.
+ */
+public class Surefire972BizarreNoClassDefIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Test
+ public void testJunit3ParallelBuildResultCount()
+ {
+ unpack( "surefire-972-bizarre-noclassdef" ).maven().withFailure().executeVerify();
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
new file mode 100644
index 0000000..d5e9fbc
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
@@ -0,0 +1,51 @@
+<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>
+ <artifactId>class-rule-boom-boom</artifactId>
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
new file mode 100644
index 0000000..5554fd9
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
@@ -0,0 +1,24 @@
+package org.apache.maven.surefire.crb;
+
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: benson
+ * Date: 3/16/13
+ * Time: 11:00 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ClassRuleIT extends Assert {
+
+ @ClassRule
+ public static ExampleClassRule rule = new ExampleClassRule(ExampleClassRule.someStaticFunction());
+
+ @Test
+ public void dummyTest() {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
new file mode 100644
index 0000000..e9f44e3
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
@@ -0,0 +1,17 @@
+<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>
+ <artifactId>class-rule</artifactId>
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
new file mode 100644
index 0000000..430f7d2
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
@@ -0,0 +1,29 @@
+package org.apache.maven.surefire.crb;
+
+import org.junit.rules.ExternalResource;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: benson
+ * Date: 3/16/13
+ * Time: 10:52 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ExampleClassRule extends ExternalResource {
+
+ public ExampleClassRule(String dummy) {
+ //
+ }
+
+ protected void before() throws Throwable {
+ System.err.println("ExampleClassRule.before()");
+ }
+
+ protected void after() {
+ System.err.println("ExampleClassRule.after()");
+ }
+
+ public static String someStaticFunction() {
+ throw new RuntimeException("Surprise!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
new file mode 100644
index 0000000..be4df33
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
@@ -0,0 +1,32 @@
+<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>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <modules>
+ <module>class-rule</module>
+ <module>boom</module>
+ </modules>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.14</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/01a3d7f6/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index 50c7498..5c6ab03 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -21,6 +21,7 @@ package org.apache.maven.surefire.common.junit4;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.report.SimpleReportEntry;
@@ -98,9 +99,13 @@ public class JUnit4RunListener
public void testFailure( Failure failure )
throws Exception
{
- ReportEntry report =
- SimpleReportEntry.withException( getClassName( failure.getDescription() ), failure.getTestHeader(),
- createStackTraceWriter( failure ) );
+ String testHeader = failure.getTestHeader();
+ if ( isInsaneJunitNullString( testHeader ) )
+ {
+ testHeader = "Failure when constructing test";
+ }
+ ReportEntry report = SimpleReportEntry.withException( getClassName( failure.getDescription() ), testHeader,
+ createStackTraceWriter( failure ) );
if ( failure.getException() instanceof AssertionError )
{
@@ -148,7 +153,26 @@ public class JUnit4RunListener
public String getClassName( Description description )
{
- return extractClassName( description );
+ String name = extractClassName( description );
+ if ( name == null || isInsaneJunitNullString( name ) )
+ {
+ // This can happen upon early failures (class instantiation error etc)
+ Description subDescription = description.getChildren().get( 0 );
+ if ( subDescription != null )
+ {
+ name = extractClassName( subDescription );
+ }
+ if ( name == null )
+ {
+ name = "Test Instantiation Error";
+ }
+ }
+ return name;
+ }
+
+ private boolean isInsaneJunitNullString( String value )
+ {
+ return "null".equals( value );
}
public static String extractClassName( Description description )