首页 > 解决方案 > 如何自动运行测试?

问题描述

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

标签: javaspring-bootmavenjunit

解决方案


您应该使用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您的代码将被编译并运行测试。


推荐阅读