简体   繁体   English

JUnit3和JUnit4之间在性能上有区别吗?

[英]Is there a performance difference between JUnit3 and JUnit4?

I would like to know if there is a difference in running a JUnit3-Test or a JUnit4-Test. 我想知道在运行JUnit3-Test或JUnit4-Test中是否有区别。 Even if it is just 5-10% improvment on the total runtime, in a big project with nightly builds this could matter. 即使总运行时间仅提高了5-10%,在一个每晚进行构建的大型项目中,这也很重要。

Subquestins are: 子任务是:

  • Does the TestRunner improved on the update to Junit4? TestRunner在Junit4的更新上是否有所改进?
  • Or does it take longer to resolve @annotation in JUnit4 style? 或者它需要更长的时间来解决@annotation在JUnit4的风格?
  • Benefits a JUnit3 written test of a JUnit4 execution? 对JUnit4执行的JUnit3书面测试有好处吗?

If possible please answer with references. 如果可能,请提供参考答案。

I suspect that given what JUnit does (mainly provide a framework for people to write tests), that the differences, if any, are negligible. 我怀疑,鉴于JUnit所做的事情(主要是为人们提供编写测试的框架),这些差异(如果有的话)可以忽略不计。 As with most performance issues and queries, you should probably perform measurements yourself for your particular scenario. 与大多数性能问题和查询一样,您可能应该针对特定情况自己进行测量。

Any test performance issues I've seen in the past relate to how the developers write the actual tests , and whether they handle issues like: 我过去遇到的任何测试性能问题都与开发人员如何编写实际测试以及他们是否处理以下问题有关:

  1. set up pre-conditions in advance for a set of tests, rather than perform set up for each individual test (eg see @BeforeClass ) 预先为一组测试设置前提条件,而不是为每个单独的测试执行设置(例如,参见@BeforeClass
  2. perform accesses to remote resources (servers, databases etc.) in situations where mocking may be preferable 在可能更喜欢模拟的情况下执行对远程资源(服务器,数据库等)的访问
  3. write tests around threading issues, with Thread.sleep() interspersed to allow for scheduling issues 围绕线程问题编写测试,并穿插Thread.sleep()以允许调度问题

If you're really concerned with test framework speed, then perhaps you should also evaluate TestNG ? 如果您真的关心测试框架的速度,那么也许您还应该评估TestNG

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

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