Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speeding up Spring unit tests [closed]

Tags:

junit

spring

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?

like image 653
Zala Pierre GOUPIL Avatar asked Nov 17 '14 04:11

Zala Pierre GOUPIL


1 Answers

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.

like image 112
mavarazy Avatar answered Sep 28 '22 00:09

mavarazy