Hi I tried to test my producer logic and I just wanted to @InjectMock an Emitter but it throw an error something like :
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipse.microprofile.reactive.messaging.Emitter
Any suggestion would be helpful
Reactive Messaging channels are based on CDI extensions, so you cannot inject a mock directly. But you can use the
InMemoryConnector
to replace the connector implementation and test your producer logic.Using the in-memory connector, you can get the sink with the channel name of your emitter and assert on received objects.
You can also check https://quarkus.io/guides/kafka#testing-without-a-broker for more information.