I have an interesting problem… I think I understand what is happening but have no clue on how to get info for it or fix it. Here is the context:
- I have a complex maven project I am converting to gradle. (attempting to change little / no source code in the conversion)
- to run integration tests I am using the docker-compose gradle plugin. this spins up rabbitmq, runs some tests and then tears it down.
- everything worked in maven ( )
- everything works when run in intelli-j (outside docker-compose plugin operation)
I have an issue where the dependencies injected into the spring context seem to “sick around” between tests. Here is the low down:
- test1 - stupid simple test that just loads the spring boot context
- test2 - this test uses mockito for a bunch of internal dependencies we do not care about. it tests the rabbitmq interaction. it marks a bunch of objects with @Mock and uses @InjectMocks
here are my observations:
- when I manually spawn rabbitmq in the background and run these tests in intelli-j… everything passes.
- when I run docker-compose to bring up / tear down my integration env.
- test2 fails if it is run after test1
- test2 passes if run alone (without test1)
My feeling is that mockito is not injecting mocks after test1 injects the real objects but I don’t understand why this would be different when running docker-compose versus out of intellij.
Is there something that I need to configure to tell gradle to re-create the spring context between tests that intelli-j is doing for me?
Any thoughts are greatly appreciated.