maven没有跳过测试 真正

问题描述 投票:0回答:1

如果我在命令行上运行maven:

mvn clean install -DskipTests

这实际上是有效的,它会跳过测试,但如果我在eclipse中这样做,它仍然会运行测试

<plugins>
       <!-- Maven Assembly Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <excludes>
                            <exclude>**/UTest*.java</exclude>
                        </excludes>
                        <maven.test.skip>true</maven.test.skip>
                        <skipTests>true</skipTests>
                        <!-- get all project dependencies -->
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>                                    <mainClass>com.example.MyMainClass/mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>
            </executions>
        </plugin>

所以我尝试了三种不同的方式,如上所示:

1) <skipTests>true</skipTests>
2) <maven.test.skip>true</maven.test.skip>
3) <excludes>...</excludes>

在eclipse中,它将始终运行测试

eclipse maven junit
1个回答
1
投票

程序集插件不运行测试。 Maven通过生命周期阶段工作。 install阶段将触发(不详尽)编译器插件,surefire,failsafe,assembly。

更多信息,What are Maven goals and phases and what is their difference?

surefire插件处理单元测试的运行,完全跳过测试,您可以将以下内容添加到插件配置中

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>

Failsafe是一个集成测试运行器。

© www.soinside.com 2019 - 2024. All rights reserved.