简体   繁体   English

有没有一种方法可以计算TestNG中的断言数量?

[英]Is there a way to count the number of assertions in TestNG?

Actually the title includes the question. 实际上标题包括问题。

I would like to know how many assertions have been evaluated in the tests. 我想知道在测试中评估了多少个断言。

You could use aspectj for this. 您可以为此使用aspectj If you define a pointcut that matches with assert calls, you can keep a counter in an aspect and report that counter after the tests have run. 如果定义了与断言调用匹配的切入点,则可以在一个方面保留一个计数器,并在测试运行后报告该计数器。

If you make the pointcut finegrained enough, you could count assertTrue() different from assertEquals(), etc.. if you would want that. 如果使切入点足够细,则可以将assertTrue()与assertEquals()等进行计数,如果需要的话。

The short answer is no. 最简洁的答案是不。

What you can do is use your own asserts and maintain a counter there. 您可以做的是使用自己的断言并在其中维护一个计数器。

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

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