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 spying EO using recent Mockito version #49

Closed
luizalfredo23 opened this issue Sep 19, 2017 · 0 comments
Closed

Error spying EO using recent Mockito version #49

luizalfredo23 opened this issue Sep 19, 2017 · 0 comments
Labels
Milestone

Comments

@luizalfredo23
Copy link

Test is throwing the following exception when running against a recent version of Mockito:

org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'boletoReference'.
Unable to create mock instance of type 'BoletoReference'
	at org.mockito.internal.runners.DefaultInternalRunner$1.withBefores(DefaultInternalRunner.java:38)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:276)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:78)
	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:84)
	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.mockito.exceptions.base.MockitoException: Unable to create mock instance of type 'BoletoReference'
	... 20 more
Caused by: org.mockito.internal.creation.instance.InstantiationException: 
Unable to create instance of 'BoletoReference$MockitoMock$1334867616'.
Please ensure the target class has a 0-arg constructor and executes cleanly.
	... 20 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.mockito.internal.creation.instance.ConstructorInstantiator.invokeConstructor(ConstructorInstantiator.java:64)
	at org.mockito.internal.creation.instance.ConstructorInstantiator.withParams(ConstructorInstantiator.java:48)
	at org.mockito.internal.creation.instance.ConstructorInstantiator.newInstance(ConstructorInstantiator.java:34)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:47)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
	at org.mockito.Mockito.mock(Mockito.java:1798)
	at org.mockito.internal.configuration.SpyAnnotationEngine.spyNewInstance(SpyAnnotationEngine.java:114)
	at org.mockito.internal.configuration.SpyAnnotationEngine.process(SpyAnnotationEngine.java:65)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:59)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
	at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
	... 20 more
Caused by: java.lang.IllegalStateException: Unabled to find an EOClassDescription for objects of class br.com.doit.money.gateway.model.BoletoReference$MockitoMock$1334867616
	at com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGenericRecord.java:98)
	at com.webobjects.eocontrol.EOGenericRecord.<init>(EOGenericRecord.java:73)
	at er.extensions.eof.ERXGenericRecord.<init>(ERXGenericRecord.java:103)
	at br.com.doit.money.gateway.model.base._BoletoReference.<init>(_BoletoReference.java:14)
	at br.com.doit.money.gateway.model.BoletoReference.<init>(BoletoReference.java:16)
	at br.com.doit.money.gateway.model.BoletoReference$MockitoMock$1334867616.<init>(Unknown Source)
	... 37 more

That is the Mockito dependency declaration in the pom.xml.

<dependency>
   <groupId>org.mockito</groupId>
   <artifactId>mockito-core</artifactId>
   <version>2.10.0</version>
   <scope>test</scope>
</dependency>
@hprange hprange added the bug label Nov 4, 2017
hprange added a commit that referenced this issue Sep 12, 2020
@hprange hprange added this to the wounit-1.4 milestone Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants