Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Mockito: "Could not initialize plugin: interface org.mockito.plugins.MockMaker" #40

Open
matteo-coni opened this issue Dec 4, 2023 · 1 comment

Comments

@matteo-coni
Copy link

I can't to combine use of mockito and badua in testing of Apache projects. In particular the error is: "Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)" when the test try to build the mock of any class. I have include any necessary library , indeed test work fine without badua and also with JaCoCo or other tool of coverage.

[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.bookkeeper.bookie.storage.ldb.WriteCachePutTest
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 1.177 s <<< FAILURE! - in org.apache.bookkeeper.bookie.storage.ldb.WriteCachePutTest
[ERROR] initializationError(org.apache.bookkeeper.bookie.storage.ldb.WriteCachePutTest)  Time elapsed: 0.014 s  <<< ERROR!

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
        at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:88)
        at jdk.proxy2/jdk.proxy2.$Proxy12.isTypeMockable(Unknown Source)
        at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:33)
        at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
        at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:250)
        at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:232)
        at org.mockito.internal.MockitoCore.mock(MockitoCore.java:83)
        at org.mockito.Mockito.mock(Mockito.java:1964)
        at org.mockito.Mockito.mock(Mockito.java:1879)
        at org.apache.bookkeeper.bookie.storage.ldb.WriteCachePutTest.getByteBuff(WriteCachePutTest.java:115)
        at org.apache.bookkeeper.bookie.storage.ldb.WriteCachePutTest.getParameters(WriteCachePutTest.java:66)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.runners.Parameterized.allParameters(Parameterized.java:280)
        at org.junit.runners.Parameterized.<init>(Parameterized.java:248)
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
        at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:362)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@4748a0f9
        at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:58)
        at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:69)
        at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:54)
        at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:29)
        at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:20)
        at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:28)
        ... 32 more`

it's possibile or known some incompatibility beetween two tool?

@andrioli
Copy link
Member

andrioli commented Dec 4, 2023

Hi @matteo-coni,

In theory, BA-DUA should work fine with Mockito.

Question: Are you using BA-DUA and JaCoCo activated at the same time? This may cause problems!

Do you have a reproducer for this bug that you can share with me ? With a reproducer will be much easier to understand what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants