Reputation: 1513
I'm struggling with setting up integration test with spring cloud stream.
let's say I need to test the following integration flow
Updating read model works asynchronously. It works fine while running the app (events get collected and consumed), it does not work when I run integration tests. Method marked with @StreamListener
simply does not get called while running tests, app doesn't event connect to message broker (kafka in my case)
I've used spring-cloud-stream-test-support
and MessageCollector
, but it gives me an opportunity to check whether an event was published and validate its payload.
What I need is to check whether the app has collected the event and reacted correctly to it.
What am I missing? Is there any sort of test binder that app subscribes to during test run?
Upvotes: 2
Views: 1308
Reputation: 174729
When using the test binder, the test binder overrides the Kafka binder by default.
To run integration tests in the same project as the unit tests, you have to configure the test to use the real binder by excluding the TestSupportBinderAutoConfiguration
.
For global exclusion, see the SCSt docs.
For exclusion in individual tests, see the Boot docs.
Finally, you can also control the list of auto-configuration classes to exclude by using the
spring.autoconfigure.exclude
property.
e.g. in @TestPropertySource
.
Upvotes: 2