From 35a772467131bdee4a4af06524723daa7eb9296d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Raupach?= Date: Sun, 10 Jul 2022 12:07:40 +0200 Subject: [PATCH] [SUREFIRE-2090] Xref link to source code with specified line number doesn't work. Missing "L" in anchor --- .../surefire/report/SurefireReportGenerator.java | 2 +- .../surefire/report/SurefireReportMojoTest.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java index 4febdd1576..b4d9d24365 100644 --- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java +++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java @@ -608,7 +608,7 @@ private void constructFailureDetails( Sink sink, LocalizedProperties bundle, Lis if ( xrefLocation != null ) { String path = fullClassName.replace( '.', '/' ); - sink.link( xrefLocation + "/" + path + ".html#" + errorLineNumber ); + sink.link( xrefLocation + "/" + path + ".html#L" + errorLineNumber ); } sink.text( fullClassName + ":" + errorLineNumber ); diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java index 4fa4298ab5..d0cde71ad4 100644 --- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java +++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java @@ -170,7 +170,7 @@ public void testBasicSurefireReportIfLinkXrefIsFalse() String htmlContent = FileUtils.fileRead( report ); - int idx = htmlContent.indexOf( "./xref-test/com/shape/CircleTest.html#44" ); + int idx = htmlContent.indexOf( "./xref-test/com/shape/CircleTest.html#L44" ); assertTrue( idx == -1 ); } @@ -195,7 +195,7 @@ public void testBasicSurefireReportIfReportingIsNull() String htmlContent = FileUtils.fileRead( report ); - int idx = htmlContent.indexOf( "./xref-test/com/shape/CircleTest.html#44" ); + int idx = htmlContent.indexOf( "./xref-test/com/shape/CircleTest.html#L44" ); assertTrue( idx < 0 ); } @@ -276,7 +276,7 @@ public void testSurefireReportSingleError() assertThat( htmlContent, containsString( ">surefire.MyTest:13" ) ); - assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#13" ) ); + assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#L13" ) ); assertThat( htmlContent, containsString( toSystemNewLine( "
"
         + "java.lang.RuntimeException: java.lang.IndexOutOfBoundsException\n"
@@ -361,7 +361,7 @@ public void testSurefireReportNestedClassTrimStackTrace()
         assertThat( htmlContent,
                     containsString( ">surefire.MyTest:13" ) );
 
-        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#13" ) );
+        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#L13" ) );
 
         assertThat( htmlContent, containsString( toSystemNewLine( "
"
         + "java.lang.RuntimeException: java.lang.IndexOutOfBoundsException\n"
@@ -424,7 +424,7 @@ public void testSurefireReportNestedClass()
         assertThat( htmlContent,
                     containsString( ">surefire.MyTest:13" ) );
 
-        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#13" ) );
+        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest.html#L13" ) );
 
         assertThat( htmlContent, containsString( toSystemNewLine( "
"
         + "java.lang.RuntimeException: java.lang.IndexOutOfBoundsException\n"
@@ -511,7 +511,7 @@ public void testSurefireReportEnclosedTrimStackTrace()
 
         assertThat( htmlContent, containsString( ">surefire.MyTest$A:45" ) );
 
-        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest$A.html#45" ) );
+        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest$A.html#L45" ) );
 
         assertThat( htmlContent, containsString( toSystemNewLine( "
"
         + "java.lang.RuntimeException: java.lang.IndexOutOfBoundsException\n"
@@ -573,7 +573,7 @@ public void testSurefireReportEnclosed()
 
         assertThat( htmlContent, containsString( ">surefire.MyTest$A:45" ) );
 
-        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest$A.html#45" ) );
+        assertThat( htmlContent, containsString( "./xref-test/surefire/MyTest$A.html#L45" ) );
 
         assertThat( htmlContent, containsString( toSystemNewLine(
             "
" + "java.lang.RuntimeException: java.lang.IndexOutOfBoundsException\n"