[英]Gradle generate custom test report
I need a bit of help building custom test reports. 我需要一些帮助来构建自定义测试报告。
Each test would have an output like 'result x', 'result y' which would then be stored in either 1 global report file or 1 report per test. 每个测试将具有类似“结果x”,“结果y”的输出,然后将其存储在1个全局报告文件或每个测试1个报告中。
A naive approach would be to use the 'tear down' part of each test to append the info in a global file. 天真的方法是使用每个测试的“拆解”部分将信息附加到全局文件中。
The output file shouldn't interfere with junit, jacoco or other reports. 输出文件不应干扰junit,jacoco或其他报告。
Can this be achieved by doing a custom gradle plugin or reusing some functionality in other plugins? 是否可以通过执行自定义gradle插件或在其他插件中重用某些功能来实现?
Thank you 谢谢
The gradle Test task supports custom TestListener s. gradle Test任务支持自定义TestListener 。 There's also convenience methods for beforeTest and afterTest 还有针对beforeTest和afterTest的便捷方法
eg: 例如:
apply plugin: 'java'
test {
afterTest { TestDescriptor td, TestResult tr ->
writeToSomeFile(td.className, td.name, tr.resultType.name())
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.