简体   繁体   English

如何使用Junit测试运行状态进行批注处理并分析结果

[英]How to do annotation processing and analyze the result with Junit test run status

In my project I have created custom annotation which I have added to important classes and methods. 在我的项目中,我创建了自定义批注,并将其添加到重要的类和方法中。

I want to process these annotation after running my junit test suites to check if my annotated methods are covered and how much coverage of those methods. 我想在运行junit测试套件后处理这些批注,以检查是否覆盖了我的批注方法以及这些方法的覆盖率。 How can I achieve this programatically? 如何以编程方式实现这一目标?

With Google reflections you can analyze JARs (or the classpath) to find the methods decorated with your custom annotation. 使用Google反射,您可以分析JAR(或类路径)以找到用自定义注释修饰的方法。

Than you can inspect the output of JUnit and link data together. 比您可以检查JUnit的输出并将数据链接在一起。 How to get the output of a JUnit run depends on how you execute your suites, but it should always be possibile to generate the report in XML format and then parse it (or directly use the API without messing with XML) 如何获取JUnit运行的输出取决于您如何执行套件,但是应该始终可能以XML格式生成报告然后对其进行解析(或直接使用API​​而不会弄乱XML)

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

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