簡體   English   中英

如何避免使用'MVN Site'運行surefire單元測試

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

每當我運行“ MVN網站”時,我所有的surefire單元測試都會執行。 有什么方法可以避免在運行mvn站點時運行surefire單元測試。 我的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>

根據插件文檔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 :以html格式創建格式正確的Surefire測試報告。 這個目標不會運行測試,它只會生成報告。 這是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