如何自动运行测试?

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

JUNIT5 中将添加哪些属性来自动运行测试? 我该如何配置?

java spring-boot maven junit
3个回答
3
投票

您应该使用 maven-surefire-plugin,例如:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-Xmx1024M ${additional.test.jvm.args}</argLine>
                <excludes>
                    <exclude>**/*ManagedTest.java</exclude>
                </excludes>
                <runOrder>alphabetical</runOrder>
            </configuration>
        </plugin>
    </plugins>
</build>

然后,如果您运行

mvn test
,您的代码将被编译并运行测试。


2
投票

您可以使用 Maven 插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <configuration>
        <includes>
            <include>**/*Test.java</include>
        </includes>
        <excludes>
            <exclude>**/integration/*ITTest.java</exclude>
        </excludes>
    </configuration>
</plugin>

有关更多信息,请参阅文档


-2
投票

如何在修改代码时自动运行测试?

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