简体   繁体   English

如何避免使用'MVN Site'运行surefire单元测试

[英]How to avoid running surefire unit test with 'mvn site'

whenever I run 'mvn site' all my surefire unit tests gets executed. 每当我运行“ MVN网站”时,我所有的surefire单元测试都会执行。 Is there any way to avoid running surefire unit tests while running mvn site. 有什么方法可以避免在运行mvn站点时运行surefire单元测试。 My pom is as mentioned below. 我的pom如下所述。 I am using the below pom in parent project and all the modules are children of this pom. 我在父项目中使用以下pom,并且所有模块都是该pom的子级。

<plugins>
    <!--For Unit tests -->
    <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${surefire.version}</version>
    </plugin>
    <!--For executing Integration tests in integration-test phase -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${failsafe.version}</version>
    <configuration>
        <excludes>
        <exclude>**/*Test.java</exclude>
        </excludes>
        <includes>
        <include>**/*IT.java</include>
        </includes>
    </configuration>
    <executions>
        <execution>
        <phase>integration-test</phase>
        <goals>
            <goal>integration-test</goal>
            <goal>verify</goal>
        </goals>
        </execution>
    </executions>
    </plugin>
</plugins>
<!--For generating unit and integration test reports -->
<reporting>
    <plugins>
    <plugin>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.7</version>
        <reportSets>
        <reportSet>
            <reports>
            <!--Disable all default reports -->
            </reports>
        </reportSet>
        </reportSets>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
        <aggregate>true</aggregate>
        <linkXRef>true</linkXRef>
        </configuration>
    </plugin>
    </plugins>
</reporting>

As per plugin documentation , use report-only 根据插件文档report-only使用report-only

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>${surefire.version}</version>
    <reportSets>
        <reportSet>
            <reports>
                <report>report-only</report>
            </reports>
        </reportSet>
    </reportSets>
</plugin>

surefire-report:report-only : Creates a nicely formatted Surefire Test Report in html format. surefire-report:report-only :以html格式创建格式正确的Surefire测试报告。 This goal does not run the tests, it only builds the reports. 这个目标不会运行测试,它只会生成报告。 This is a workaround for https://issues.apache.org/jira/browse/SUREFIRE-257 这是https://issues.apache.org/jira/browse/SUREFIRE-257的解决方法

尝试使用mvn -DskipTests=true site

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM