3

每当我运行“mvn site”时,我所有的肯定单元测试都会被执行。有什么方法可以避免在运行 mvn 站点时运行万无一失的单元测试。我的 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>
4

2 回答 2

1

根据插件文档,使用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:以 html 格式创建格式良好的 Surefire 测试报告。这个目标不运行测试,它只构建报告。这是https://issues.apache.org/jira/browse/SUREFIRE-257的解决方法

于 2018-06-04T19:28:30.273 回答
0

尝试使用mvn -DskipTests=true site.

于 2013-11-02T12:35:25.063 回答