Skip to content
Advertisement

How to ignore a method call inside a method that is being tested?

I am trying to make a test pass with mockmvc and it is failing with the following error message:

Caused by: org.apache.kafka.common.config.ConfigException

We have Kafka in our service layer as a dependency, and it is being called inside the method we are testing. Is there a way to ignore that specific call during tests? In the example below, we want to ignore the notifyHrcOfInfectedUser() during testing.

JavaScript

Advertisement

Answer

Are you able to mock the kafkaSender object? Then we can do something like…

JavaScript

Update…

Or to be more accurate

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement