Maven fail-safe not executing tests

前端 未结 10 1582
孤城傲影
孤城傲影 2020-12-28 12:23

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

相关标签:
10条回答
  • 2020-12-28 13:05

    For me, surefire:verify did not run any tests. I had to use surefire:integration-test.

    0 讨论(0)
  • 2020-12-28 13:06

    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>
    
    0 讨论(0)
  • 2020-12-28 13:06

    I'm using java 8, failsafe plugin version 2.22.2 => tests not running problem, to solve this I added next:

    <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-failsafe-plugin</artifactId>
         <version>${surefire.plugin.version}</version>
         <dependencies>
             <dependency>
                 <groupId>org.apache.maven.surefire</groupId>
                 <artifactId>surefire-junit47</artifactId>
                 <version>2.22.2</version>
             </dependency>
        </dependencies>
         <executions>
             <execution>
                 <id>integration</id>
                 <phase>integration-test</phase>
                 <goals>
                     <goal>integration-test</goal>
                </goals>
            </execution>
            <execution>
                <id>verify</id>
                <phase>verify</phase>
                <goals>
                    <goal>verify</goal>
                </goals>
            </execution>
         </executions>
    </plugin>
    
    0 讨论(0)
  • 2020-12-28 13:09

    You need to rename your test class.

    You can find the names the plugin looks for by default in the documentation, as pointed out by @acdcjunior:

    By default, the Failsafe Plugin will automatically include all test classes with the following wildcard patterns:

    • "**/IT*.java" - includes all of its subdirectories and all java filenames that start with "IT".
    • "**/*IT.java" - includes all of its subdirectories and all java filenames that end with "IT".
    • "**/*ITCase.java" - includes all of its subdirectories and all java filenames that end with "ITCase".
    0 讨论(0)
提交回复
热议问题