title: Actually, there were zero interactions with this mock. Embedded Kafka Spring test
body: <p>I'm trying to see if a method from Service class is invoked when the consumer consumes a message from Kafka topic but i'm getting the error that there is no zero interactions with the Mock. When the test is running it consumes the message and I can see on terminal that the service method is actually invoked (i tried with prints), but it is not passing the test.</p>
  <p>My Consumer class:</p>
  <pre><code>@Component
  public class Consumer {
    
      @Autowired
      private Service service;
  
      @KafkaListener(topics = &quot;topic&quot;)
      public void consume(String message) { 
          service.add();
      }
  }
  </code></pre>
  <p>The test:</p>
  <pre><code>@SpringBootTest
  @RunWith(MockitoJUnitRunner.class)
  @DirtiesContext
  @EmbeddedKafka(partitions = 1, brokerProperties = { &quot;listeners=PLAINTEXT://localhost:9092&quot;, &quot;port=9092&quot; })
  class ConsumerTest {
  
    @Mock( lenient = true)
    private Service service;
  
    @Autowired
    private KafkaTemplate&lt;String, String&gt; kafkaTemplate;
  
    @InjectMocks
    private Consumer consumer;
  
    @Test
    public void givenEmbeddedKafkaBroker_whenExistsTemperatureMessageInTopic_thenMessageReceivedByConsumerAndServiceInvoked() 
      throws Exception {
  
        String message = &quot;Hello&quot;;
  
        kafkaTemplate.send(&quot;topic&quot;, message);
  
        Mockito.verify(service, times(1)).add();
    }
  }
  </code></pre>