Maven fail-safe not executing tests

maven failsafe plugin
maven failsafe test name
maven-failsafe execution id
maven testing
maven not running tests
maven acceptance tests
could not find goal test in plugin org apache maven plugins maven-failsafe-plugin
run integration tests with failsafe

I've combed StackOverflow and many other sites, have found many other related posts and have followed all said suggestions, but in the end, failsafe is skipping my tests.

My JUnit test is located here: myModule/src/main/test/java/ClientAccessIT.java

I am skipping surefire because there are no unit tests in this module:

<!-- POM snippet -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
  <skip>true</skip>
  </configuration>
</plugin>

And I'm trying to run integration tests with failsafe:

<!-- POM snippet -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <executions>
        <execution>
            <id>run-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

However, when I run mvn verify I see this:

[INFO] --- maven-failsafe-plugin:2.14.1:integration-test (run-tests) @ rest-services-test ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

I spent the last 4 1/2 hours scouring, any help would be appreciated. The only other thing that may be worth mentioning is that I have Cargo setting up and tearing down a Tomcat container. Does anybody see the glaring problem?

Maven Failsafe Plugin – Inclusions and Exclusions of Tests, By default, the Failsafe Plugin will automatically include all test classes with If the test classes do not follow any of these naming conventions, then To have the plugin scan dependencies to find test classes to execute, use  I've combed StackOverflow and many other sites, have found many other related posts and have followed all said suggestions, but in the end, failsafe is skipping my tests.

I had a similar problem. If there aren't any test classes compiled to target/test-classes then check your pom file and ensure that the packaging isn't 'pom'.

Maven Failsafe Plugin – failsafe:verify, User property is: encoding. <failIfNoTests>, Boolean, 2.4, Set this to "true" to cause a failure if there are no tests to run. I have a problem with Maven Failsafe plugin that does not execute my tests. The test is stored in folder \src\test\java\ and its name is Test1IT.java which is in the correct format. In addition I have to exclude this test in Maven compiler plugin,because this test is dependent on jetty run. Here is the pom.xml

Your tests are not in the default test sources directory src/test/java. See:

https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

myModule/src/main/test/java/ClientAccessIT.java

should be:

myModule/src/test/java/ClientAccessIT.java

You could also update your pom file (if you really wanted tests to live in main) to include:

<build>
    <testSources>
        <testSource>
            <directory>src/main/test</directory>
        </testSource>
    </testSources>
</build>

Maven Failsafe Plugin – failsafe:integration-test, By default, Surefire does not execute tests in parallel. You can set the parameter parallel to none to explicitly disable parallel execution (e.g. when  This release includes version 2.22.0 of the Maven Surefire Plugin (unit test runner) and 2.22.0 of the Maven Failsafe (integration test runner) plugin. The 2.22.0 releases include support for JUnit.

For multi-module projects, the child project needs to have the plugin declared as followed,

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
 </plugin>

version inherits from parent pom. Without the above defined, the plugin in parent pom alone will not work.

Maven Failsafe Plugin – Skipping Tests, Surefire Plugin, this will have the effect of not running any tests. If, instead, you want to skip only the integration tests being run by the Failsafe  This release includes version 2.22.0 of the Maven Surefire Plugin (unit test runner), and 2.22.0 of the Maven Failsafe (integration test runner) plugin. The 2.22.0 releases include support for JUnit. Prior to these releases, to run Junit 5 tests under Maven, you needed to include a JUnit provider dependency for the Maven Surefire plugin.

I also had a similar problem but needed the packaging element to be "pom". Make sure your test source files are being compiled and added to the .../target/test-classes folder using the maven-compiler-plugin:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.version}</version>
            <executions>
                <execution>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Maven Failsafe Plugin – Introduction, The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute. If, instead, you want to skip only the integration tests being run by the Failsafe Plugin, you would use the skipITs property instead: mvn install -DskipITs If you absolutely must, you can also use the maven.test.skip property to skip compiling the tests.

Maven Failsafe Plugin – Usage - Apache Maven, The POJO provider above allows you to write tests that do not depend on either of JUnit and TestNG. It behaves in the same way, running all  The Failsafe Plugin is used during the integration-test and verify phases of the build lifecycle to execute the integration tests of an application. The Failsafe Plugin will not fail the build during the integration-test phase, thus enabling the post-integration-test phase to execute.

Integration tests not getting executed using Maven failsafe plugin , I have an application which has both junit and htmlunit tests. The problem is that when I run 'mvn integration-test" instead of executing htmlunit  By default, Surefire does not execute tests in parallel. You can set the parameter parallel to none to explicitly disable parallel execution (e.g. when disabling parallel execution in special Maven profiles when executing coverage analysis). User property is : parallel.

Maven Failsafe Plugin Understanding, Maven Failsafe Plugin runs integration tests for your Maven project. a properly tear down—phase post-integration-test will not be executed. During development, you may run a single test class repeatedly. To run this through Maven, set the it.test property to a specific test case. The value for the it.test parameter is the name of the test class (without the extension; we'll strip off the extension if you accidentally provide one).

Comments
  • That does not seem to be true: maven.apache.org/surefire/maven-failsafe-plugin/examples/… - it says the default patterns are **/IT*.java, **/*IT.java, **/*ITCase.java.
  • @acdcjunior beat me to it; here's a direct link to the relevant documentation page: maven.apache.org/surefire/maven-failsafe-plugin/…
  • "**/*IT.java" - includes all of its subdirectories and all java filenames that end with "IT". Wouldn't ClientAccessIT.java meet the qualifications of this pattern?
  • The example "ClientAccessIT.java" clearly matches *IT.java. So this answer is just useless and confusing.
  • if you are usin JUnit 5 you can include them by filtering and using tags: maven.apache.org/surefire/maven-failsafe-plugin/examples/…
  • Thanks. That was the problem for me. Not at all obvious!
  • What is "packaging isn't pom"? Any hint?
  • Look in your effective pom.xml for the tag "packaging". Look at this link for a bit more about the packaging tag. maven.apache.org/pom.html. the key is to ensure that the value of that tag is not "pom".
  • This should be the accepted answer. The given example clearly doesn't work because of this.
  • Did you mean <testResources> or <testSourceDirectory>? I cannot find element <testSources>