8

I have JUnit 4 test classes that all inherit from a common class. This parent class provide services such as minimal tests setup and DB management.

But this parent class is long to execute mainly because my Spring context loading is slow.

Is there any way to execute the code from the parent class only once for all the tests classes that inherit from it?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118

1 Answers1

4

You can take a look at similar question for reference:

Reuse spring application context across junit test classes

This works good with batch of tests. I personally use single configuration for all tests in one module, with small downside, which is that even if test requires only part of the context, it is still better to load whole context, so it might take more time for individual test to execute, but test run faster at batches.

Community
  • 1
  • 1
mavarazy
  • 7,562
  • 1
  • 34
  • 60
  • Thanks, it works like a charm! The difficulty has been to retrieve the application context in order to bootstrap my test WicketApplication, but once done, it is has been a piece of cake! – Zala Pierre GOUPIL Nov 17 '14 at 08:54