Fork me on GitHub

Source Code Cross Reference

There are times when we need to know right away the line number of the source code that caused the failure of the test. The Surefire Report Plugin has the capability to cross reference the source code that made the test failed. To be able to activate it, the maven-jxr-plugin should also be declared in the <reporting> section of the POM along with the maven-surefire-report-plugin. For more details, please read the documentation of the Maven JXR Plugin.

<project>
  [...]
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.16</version>
        <configuration>
          <!-- place your configuration here -->
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>2.1</version>
      </plugin>
    </plugins>
  </reporting>
  [...]
</project>

After executing mvn site for site generation, You'll notice that from the Failure Details section of the report, the link is available to redirect you to the source code that caused the failure.

From the figure below the code that caused the failure is com.test.proj.AppTest:36

Failure Details

The link will redirect you to the source by clicking it.

The source

Disable the Cross Reference Link

To disable the link to the source code, the linkXRef property should be set to false. Or another way is by not declaring the maven-jxr-plugin to the <reporting> section.