简体   繁体   English

Junit测试套件以编程方式执行

[英]Junit test suite execution programmatically

I want to build a tool in java, where I can see the progress of my Junit test suite execution. 我想在Java中构建一个工具,在这里可以看到Junit测试套件执行的进度。 Like below. 像下面。

  1. Current executing class. 当前执行的类。
  2. How many test cases completed(Passed, Failed)? 完成了多少个测试用例(通过,失败)?
  3. How many test cases pending? 有多少测试用例待处理?

From this information, I want to build a graphical report. 根据这些信息,我想构建一个图形报告。

How to start? 如何开始?

The preferred external facade seems to be JUnitCore , which offers a series of useful run(...) overloads. 首选的外部外观似乎是JUnitCore ,它提供了一系列有用的run(...)重载。 Call JUnitCore.addListener with a RunListener implementation and you should be able to get the notifications you need. 使用RunListener实现调用JUnitCore.addListener ,您应该能够获取所需的通知。

Note that the total number of test cases pending may not be easy to get ahead of time; 注意未决的测试用例总数可能不容易提前获得; the test count is available as part of the Description object but by default JUnit doesn't seem to create all the runners and Descriptions until immediately before their run. 测试计数可以作为Description对象的一部分使用,但是默认情况下,JUnit似乎不会在运行之前立即创建所有运行器和Descriptions。

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

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