【发布时间】:2017-03-22 06:41:01
【问题描述】:
有sereral test,有些太慢了。可以将 maven 配置为在运行 2000 毫秒时跳过/失败测试吗?
【问题讨论】:
-
可以使用maven surefire插件的
forkedProcessTimeoutInSeconds。
标签: java maven junit maven-surefire-plugin
有sereral test,有些太慢了。可以将 maven 配置为在运行 2000 毫秒时跳过/失败测试吗?
【问题讨论】:
forkedProcessTimeoutInSeconds。
标签: java maven junit maven-surefire-plugin
正如@KrishnanunniPV 所指出的,forkedProcessTimeoutInSeconds 可以帮助您解决这个问题。如果您不介意测试失败,您只需要在您的 pom 中添加构建部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkedProcessTimeoutInSeconds>2</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
如果您希望构建成功,即使超时已过,您可以这样做:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkedProcessTimeoutInSeconds>2</forkedProcessTimeoutInSeconds>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
【讨论】:
我认为最好例如说需要太长时间的测试是集成测试(例如,将它们作为 IT 后缀),然后让 maven 在启用 maven 集成测试配置文件时运行它们。
【讨论】: