【问题标题】:How to automatically run tests?如何自动运行测试?
【发布时间】:2021-04-29 10:54:01
【问题描述】:

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

【问题讨论】:

    标签: java spring-boot maven junit


    【解决方案1】:

    您应该使用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>
      

      欲了解更多信息,请参阅doc

      【讨论】:

        猜你喜欢
        • 2019-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-21
        • 1970-01-01
        • 2013-06-30
        • 2023-03-10
        相关资源
        最近更新 更多