简体   繁体   English

在gradle测试输出中添加时间戳

[英]Adding time stamp to gradle test output

We use function tests in a java project that we run with junit and gradle. 我们在用junit和gradle运行的Java项目中使用功能测试。 They take some time. 他们需要一些时间。 Several minutes per test and we have 200. The test output looks something like this: 每次测试几分钟,我们有200分钟。测试输出看起来像这样:

TEST testname1(location) PASSED/FAILED
TEST testname2(location) PASSED/FAILED

So when we look at the log we don't know if it was test1 or test2 that took time. 因此,当我们查看日志时,我们不知道是花费了时间还是test1或test2。 Is it possible to add a timestamp to the gradle output? 是否可以在gradle输出中添加时间戳?

datetime: TEST testname1(location) PASSED/FAILED
datetime: TEST testname2(location) PASSED/FAILED

And also is it possible to write testname before we know if the test passes or failes? 还有可能在我们知道测试通过还是失败之前写下测试名称? So if a test hangs we will see which test that is hanging? 因此,如果测试挂起,我们将看到哪个测试挂起?

The new test logging feature in Gradle 1.1 will help you with this. Gradle 1.1中的新测试记录功能将帮助您实现这一目标。 You can already try 1.1-rc-2 today. 您现在可以尝试使用1.1-rc-2。

The other options is to implement and register a custom org.gradle.api.tasks.testing.TestListener . 其他选项是实现和注册自定义org.gradle.api.tasks.testing.TestListener See the java/testListener sample in the full Gradle distribution. 请参阅完整Gradle发行版中的java / testListener示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM