'Maven ignoring tests on build

Currently trying to test a project and for some reason, it won't run the tests when using mvn clean install. Strangely enough though, right-clicking on the project and do Run 'All Tests' on Intellij, runs all the tests well.

The folder is called test, with the tests having a Test added after the name of the class they are testing. I have this configuration in the POM file set up:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>11</release>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
            </plugin>

with the java version being set as such: <java.version>11</java.version>

and the junit dependency being set like so:

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

This will result in:

[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ ******* ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Usually I don't need to even add the maven-surefire-plugin under the plugins tag, although I did this to specify the version, maybe that might help but it's of no use.

Any idea what the issue might be?

UPDATE 1:

Added some configuration for the surefire plugin: <useModulePath>false</useModulePath>

Logs from mvn -X test: https://controlc.com/0e9faba9



Solution 1:[1]

The version 3.0.0-M6 has been deployed to the Maven Central repository. This issue is fixed. Pls check the POM and the configuration useModulePath=false as a workaround. http://quabr.com:8182/66637732/maven-ignoring-tests-on-build Now the workaround can be removed.

Solution 2:[2]

Yes we have a bug in surefire 3.0.0-M5 (when JDK 9+ and no JPMS is used) but we published the workaround on the Stackoverflow several times.

Pls check it out with a temporal workaround

mvn test -Dsurefire.useModulePath=false

The fix is already done and it will be released in the version 3.0.0-M6. There the workaround useModulePath=false would not be needed anymore.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tibor17
Solution 2 tibor17