Author: krosenvold
Date: Thu Jan 20 14:10:44 2011
New Revision: 1061306
URL: http://svn.apache.org/viewvc?rev=1061306&view=rev
Log:
[SUREFIRE-260] Test methods with identical names dont work in report
Fixed with HTML unit integration test
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java
(with props)
Modified:
maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
maven/surefire/trunk/surefire-integration-tests/pom.xml
Modified:
maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java?rev=1061306&r1=1061305&r2=1061306&view=diff
==============================================================================
---
maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
(original)
+++
maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
Thu Jan 20 14:10:44 2011
@@ -427,10 +427,10 @@ public class SurefireReportGenerator
sink.rawText( " <div class=\"detailToggle\"
style=\"display:inline\">" );
- sink.link( "javascript:toggleDisplay('" +
testCase.getName() + "');" );
+ sink.link( "javascript:toggleDisplay('" +
toHtmlId(testCase.getFullName()) + "');" );
- sink.rawText( "<span style=\"display: inline;\" "
+ "id=\"" + testCase.getName()
- + "off\">+</span><span id=\"" +
testCase.getName() + "on\" "
+ sink.rawText( "<span style=\"display: inline;\" "
+ "id=\"" + toHtmlId(testCase.getFullName())
+ + "off\">+</span><span id=\"" +
toHtmlId(testCase.getFullName()) + "on\" "
+ "style=\"display: none;\">-</span> " );
sink.text( "[ Detail ]" );
sink.link_();
@@ -466,7 +466,7 @@ public class SurefireReportGenerator
sink.tableCell();
sink.rawText(
- " <div id=\"" + testCase.getName() +
"error\" style=\"display:none;\">" );
+ " <div id=\"" +
toHtmlId(testCase.getFullName()) + "error\" style=\"display:none;\">" );
Iterator it = detail.iterator();
@@ -500,6 +500,10 @@ public class SurefireReportGenerator
sink.section1_();
}
+
+ private String toHtmlId(String id){
+ return id.replace(".", "_");
+ }
private void constructFailureDetails( Sink sink, ResourceBundle bundle,
List failureList )
{
Iterator failIter = failureList.iterator();
Modified: maven/surefire/trunk/surefire-integration-tests/pom.xml
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/pom.xml?rev=1061306&r1=1061305&r2=1061306&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/pom.xml Thu Jan 20 14:10:44
2011
@@ -90,6 +90,12 @@
<artifactId>plexus-utils</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.8</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java?rev=1061306&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java
Thu Jan 20 14:10:44 2011
@@ -0,0 +1,68 @@
+package org.apache.maven.surefire.its;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlDivision;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSpan;
+
+import java.io.File;
+import java.net.URI;
+
+/**
+ * Test Surefire-570 Multiple report directories
+ *
+ * @author Kristian Rosenvold
+ */
+public class Surefire260TestWithIdenticalNamesIT
+ extends SurefireVerifierTestClass
+{
+
+ public Surefire260TestWithIdenticalNamesIT()
+ {
+ super( "/surefire-260-testWithIdenticalNames" );
+ }
+
+ public void testWithIdenticalNames()
+ throws Exception
+ {
+
+ failNever();
+ executeTest();
+ reset();
+ execute("surefire-report:report" );
+
+ File siteFile = getSiteFile( "surefire-report.html" );
+ final URI uri = siteFile.toURI();
+
+ final WebClient webClient = new WebClient();
+ webClient.setJavaScriptEnabled(true);
+ final HtmlPage page = webClient.getPage(uri.toURL());
+
+ final HtmlAnchor a = (HtmlAnchor) page.getByXPath("//a[contains(@href,
'surefire260_TestB_testDup')]").get(0);
+ final HtmlDivision content = (HtmlDivision)
page.getElementById("surefire260_TestB_testDuperror");
+ assertTrue(content.getAttribute("style").contains("none"));
+ a.click();
+ assertFalse(content.getAttribute("style").contains("none"));
+ webClient.closeAllWindows();
+ }
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire260TestWithIdenticalNamesIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml?rev=1061306&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml
Thu Jan 20 14:10:44 2011
@@ -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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>surefire-260-testsWithIdenticalNames</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>surefire-260-testsWithIdenticalNames</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.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>
+ <dependencies>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <dependencies>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java?rev=1061306&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java
Thu Jan 20 14:10:44 2011
@@ -0,0 +1,14 @@
+package surefire260;
+import junit.framework.TestCase;
+
+
+public class TestA
+ extends TestCase
+{
+ public void testOne() {
+ }
+
+ public void testDup() {
+ fail("This is what we want");
+ }
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestA.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java?rev=1061306&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java
Thu Jan 20 14:10:44 2011
@@ -0,0 +1,11 @@
+package surefire260;
+import junit.framework.TestCase;
+
+
+public class TestB
+ extends TestCase
+{
+ public void testDup() {
+ fail("This is what we want");
+ }
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestB.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java?rev=1061306&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java
Thu Jan 20 14:10:44 2011
@@ -0,0 +1,11 @@
+package surefire260;
+import junit.framework.TestCase;
+
+
+public class TestC
+ extends TestCase
+{
+ public void testDup() {
+ fail("This is what we want");
+ }
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-260-testWithIdenticalNames/src/test/java/surefire260/TestC.java
------------------------------------------------------------------------------
svn:eol-style = native