I am trying to unit test a class which uses KafkaAvroDeserializer to deserialize an object. I would like to mock the KafkaAvroDeserializer so that I can test the business logic. However, when I am trying to mock KafkaAvroDeserializer, I get the following error:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class io.confluent.kafka.serializers.KafkaAvroDeserializer.
error-log-1
error-log-2
error-log-3
error-log-4
Jdk: OpenJdk17
Gradle configuration
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0'
testImplementation 'org.mockito:mockito-core:2.23.4'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testImplementation 'net.javacrumbs.json-unit:json-unit:1.30.0'
testImplementation(
'org.mockito:mockito-core:2.22.0',
"io.opentracing:opentracing-mock:0.31.0"
)
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
Aju is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.