We have some integration tests(written using spring framework) that are failing due to bean initialisation exception which eventually leads to Failed to load ApplicationContext
. As per my understanding from spring testing docs , the loading of ApplicationContext
happens at class level, so my doubt is -
Once the
ApplicationContext
fails (i.e.Failed to load ApplicationContext
) due to bean initialisation exception during integration test class run, does theApplicationContext
try to spin up again(will be failing eventually) for each individual integration tests present in that particular integration test class ?- Asking above scenario because we are seeing huge spike in number of connections to postgres when bean failure happens, it seems like for every integration test present(which eventually fails due to
Failed to load ApplicationContext
) in the integration test class, spring tries to create a new connection to postgres and doesn't destroy it beforeApplicationContext
failure. How can we stop this, please help with some suggestions.
- Asking above scenario because we are seeing huge spike in number of connections to postgres when bean failure happens, it seems like for every integration test present(which eventually fails due to
Also, once we get
Failed to load ApplicationContext
, is there a way to programmatically terminate the run of all the integration tests completely automatically ? If yes, please help how to achieve it ? Thanks.
Testing framework - junit + Spring
Update: Mentioned testing framework used.