lundi 26 juin 2017

How to run JUnit rule once per ApplicationContext

Spring "test context" supports application context caching - multiple integration tests with the same context definition will start the context only once and share it. It's great for speeding up tests.

I want to use testcontainers to launch required dependencies (which use junit rules), but I also want to launch the dependency only once for all tests that share the same ApplicationContext.

How to do that? I want to setup environment once per ApplicationContext, but I don't see any mechanism which would allow that.

I could register a Bean or Configuration that does that, but it's not a good approach and it creates problems with passing ports/hostnames to Spring (it's already too late)

Aucun commentaire:

Enregistrer un commentaire