You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I run tests with ./mvnw test, all tests are green. In the continuous testing mode, however, some tests are failing with the exception below. The stack trace suggests the class is not public and indeed it is package private.
When I change the classes to be public the error is gone, but the tests still fail with NPE because mocking is still not working and the real class constructor is called.
Is this a known issue in quarkus continuous testing
Quarkus version: 3.6.4, mockito version inherited from quarkus bom
Thanks!
(Test runner thread) ==================== TEST REPORT #1 ====================
(Test runner thread) Test FooBarBazFacadeTest#getBazs() failed
: org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.acme.serv.ServiceAbc.
Mockito can only mock non-private & non-final classes, but the root cause of this error might be different.
Please check the full stacktrace to understand what the issue is.
If you're still not sure why you're getting this error, please open an issue on GitHub.
Java : 21
JVM vendor name : Amazon.com Inc.
JVM vendor version : 21.0.1+12-LTS
JVM name : OpenJDK 64-Bit Server VM
JVM version : 21.0.1+12-LTS
JVM info : mixed mode, emulated-client, sharing
OS name : Linux
OS version : 5.15.133.1-microsoft-standard-WSL2
Underlying exception : org.mockito.exceptions.base.MockitoException:
Cannot create mock for class com.acme.serv.ServiceAbc
The type is not public and its mock class is loaded by a different class loader.
This can have multiple reasons:
- You are mocking a class with additional interfaces of another class loader
- Mockito is loaded by a different class loader than the mocked type (e.g. with OSGi)
- The thread's context class loader is different than the mock's class loader
at com.acme.serv.FooBarBazFacadeTest.setUp(FooBarBazFacadeTest.java:32)
Caused by: org.mockito.exceptions.base.MockitoException:
Cannot create mock for class com.acme.serv.ServiceAbc
The type is not public and its mock class is loaded by a different class loader.
This can have multiple reasons:
- You are mocking a class with additional interfaces of another class loader
- Mockito is loaded by a different class loader than the mocked type (e.g. with OSGi)
- The thread's context class loader is different than the mock's class loader
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
... 1 more
Further down in an another test:
Underlying exception : org.mockito.exceptions.base.MockitoException:
Cannot create mock for class com.acme.serv.FooBarData
The type is not public and its mock class is loaded by a different class loader.
This can have multiple reasons:
- You are mocking a class with additional interfaces of another class loader
- Mockito is loaded by a different class loader than the mocked type (e.g. with OSGi)
- The thread's context class loader is different than the mock's class loader
at com.acme.serv.FooBarDateTest.mockData(FooBarDateTest.java:58)
at com.acme.serv.FooBarDateTest.createFooBarDate(FooBarDateTest.java:67)
at com.acme.serv.FooBarDateTest.lambda$debug$0(FooBarDateTest.java:101)
at org.assertj.core.api.ThrowableAssert.catchThrowable(ThrowableAssert.java:63)
at org.assertj.core.api.NotThrownAssert.isThrownBy(NotThrownAssert.java:43)
at com.acme.serv.FooBarDateTest.debug(FooBarDateTest.java:101)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:728)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:218)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:214)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:139)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorserv.invokeAll(SameThreadHierarchicalTestExecutorserv.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorserv.invokeAll(SameThreadHierarchicalTestExecutorserv.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorserv.submit(SameThreadHierarchicalTestExecutorserv.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:198)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.j)va:169
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:93)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:58)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:141)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:57)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:103)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:94)
at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:52)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:70)
at io.quarkus.deployment.dev.testing.JunitTestRunner$2.run(JunitTestRunner.java:224)
at io.quarkus.deployment.dev.testing.ModuleTestRunner$2.run(ModuleTestRunner.java:89)
at io.quarkus.deployment.dev.testing.TestSupport.runInternal(TestSupport.java:467)
at io.quarkus.deployment.dev.testing.TestSupport$3.run(TestSupport.java:387)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.mockito.exceptions.base.MockitoException:
Cannot create mock for class com.acme.serv.FooBarData
The type is not public and its mock class is loaded by a different class loader.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!,
when I run tests with
./mvnw test
, all tests are green. In the continuous testing mode, however, some tests are failing with the exception below. The stack trace suggests the class is not public and indeed it is package private.When I change the classes to be public the error is gone, but the tests still fail with NPE because mocking is still not working and the real class constructor is called.
Is this a known issue in quarkus continuous testing
Quarkus version: 3.6.4, mockito version inherited from quarkus bom
Thanks!
Further down in an another test:
Beta Was this translation helpful? Give feedback.
All reactions