1

I would like to know if there is a difference in running a JUnit3-Test or a JUnit4-Test. Even if it is just 5-10% improvment on the total runtime, in a big project with nightly builds this could matter.

Subquestins are:

  • Does the TestRunner improved on the update to Junit4?
  • Or does it take longer to resolve @annotation in JUnit4 style?
  • Benefits a JUnit3 written test of a JUnit4 execution?

If possible please answer with references.

Simulant
  • 19,190
  • 8
  • 63
  • 98
  • 5
    Frankly, I doubt you would gain anything significant anyway: most of the time taken by test suite executions comes from the code of the tests, not from the code of the test framework. If it's not the case, then your tests should already run really fast. – JB Nizet Jul 17 '12 at 13:16
  • I've been looking at JUnit test reports (Cobertura) and realized that the line-coverage and branch-coverage stats are possible by Java's Instrumentation API's? Now if this is the case, then wouldn't this significantly impact testing performance/time? – Jeach Sep 29 '13 at 05:50

1 Answers1

8

I suspect that given what JUnit does (mainly provide a framework for people to write tests), that the differences, if any, are negligible. 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 (e.g. see @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

If you're really concerned with test framework speed, then perhaps you should also evaluate TestNG ?

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440