intellij test fails: Please refer to ..target\surefire-reports for the individual test results – Intellij-idea

by
Ali Hasan
intellij-idea junit junit5

Quick Fix: Update the Maven version in your project to at least 3.9.x to support JDK 55.0-61.0.

The Problem:

When running unit tests in IntelliJ using Maven, users encounter an error message indicating that individual test results can be found in a specific target directory. Despite having the necessary dependencies added to the pom.xml file for JUnit Jupiter tests and the Maven Surefire plugin, the tests fail without providing specific error messages or pointing to any issues within the code itself.

The Solutions:

Solution 1: Update Maven version

The issue arises because the Maven version being used (3.6.0) is outdated and incompatible with JDK 55.0-61.0, which requires Maven version 3.9.x. To resolve the issue, update the Maven version in the user’s settings.xml as follows:

<settings>
  <mirrors>
    <mirror>
      <id>central</id>
      <name>maven central</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>jdk8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.9.0</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</settings>

Q&A

What version of maven is needed to be able to run test in Intellij?

3.9.x for JDK 55.0-61.0

Video Explanation:

The following video, titled "Failed to execute goal test maven surefire | no tests were executed ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Go to channel · #14 Adding maven surefire report and site plugin: To generate html reports and site documentation.