dhamini-poornachandra / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Annotation Type Spy throwing NotAMockException when mocking object creation #330

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
>Either run the attached test case, or...
>1. Create a spy object using the @Spy annotation
>2. Create a mock object using the @Mock annotation
>3. Create a public method in the spy class that returns an instance >of the 
mock object
>4. Include the following in the test method:
>   doReturn(mock).when(spy).makeMockObject(); 

What is the expected output? What do you see instead?
>Expected: runs without error.
>Actual: throws a NotAMockException.

What version of the product are you using? On what operating system?
>Resources: Mockito 1.9
>1. junit-4.10
>2. objenesis-1.0.jar
>3. mockito-core-1.9.0.jar
>4. mockito-all-1.7.jar
>Operating System: Windows XP

Please provide any additional information below.
>This occurred when I attempted mocking object creation as shown in >pattern 1 
of this wiki entry -

http://code.google.com/p/mockito/wiki/MockingObjectCreation?ts=1332544670&update
d=MockingObjectCreation

Original issue reported on code.google.com by markehe...@gmail.com on 26 Mar 2012 at 8:03

GoogleCodeExporter commented 8 years ago
It's important to note that this worked when I created a spy object without the 
@Spy annotation.

Original comment by markehe...@gmail.com on 26 Mar 2012 at 8:05

GoogleCodeExporter commented 8 years ago
Attached is the test case.

Original comment by markehe...@gmail.com on 26 Mar 2012 at 8:11

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

This is most probably an issue with your class path : try to remove the old 
Mockito, and it should work as expected.

Also please ask the mailing list first if you are unsure about the bu ;)

Hope that helps,
Brice

Original comment by brice.du...@gmail.com on 27 Mar 2012 at 3:40

GoogleCodeExporter commented 8 years ago
Yep, that was it. Next time I'll make sure I ask the mailing list first! 
Thanks, Brice.

~Mark

Original comment by markehe...@gmail.com on 27 Mar 2012 at 4:06

GoogleCodeExporter commented 8 years ago
Ok cool :)

I'll invalidate the issue then.

Have fun with Mockito.

Brice

Original comment by brice.du...@gmail.com on 27 Mar 2012 at 4:11