ahmaddarawshi / powermock

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

WhiteBox.setInternalState() does not always work when the argument is created with @Mock #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

WhiteBox.setInternalState(Object, Object) does not work when the second
argument is created by using the @Mock annotation. However,
WhiteBox.setInternalState(Object, String, Object) works.

###########################################################################

What is the expected output? What do you see instead?

The test should pass. 

org.powermock.reflect.exceptions.FieldNotFoundException: No field
assignable to "java.lang.Object" could be found in the class hierarchy of
SomeClass.

###########################################################################

What version of the product are you using? On what operating system?

PowerMock 1.2.5

Ubuntu

###########################################################################

Please provide any additional information below.

5 files have been attached:
* InternalInterface.java is an interface with a method
* SomeClass.java is a class that has a private InternalInterface member
* FirstPassingTest.java is a junit test that creates an instance of
InternalInterface.java using the Mockito.mock() method and uses
setInternalState(Object, Object)
* SecondPassingTest.java is a junit test that creates an instance of 
InternalInterface.java using the @Mock annotation and uses
setInternalState(Object, String, Object)
* FailingTest.java is a junit test that creates an instance of
InternalInterface.java using the @Mock annotation and uses
setInternalState(Object, Object)

Original issue reported on code.google.com by mat...@gmail.com on 8 Oct 2009 at 11:57

Attachments:

GoogleCodeExporter commented 9 years ago
Could you try PowerMock 1.3 and see if you get the same results then?

Original comment by johan.ha...@gmail.com on 9 Oct 2009 at 6:09

GoogleCodeExporter commented 9 years ago
Now the tests work, well done! I am sorry, I missed that you released the 1.3 
version
the other day...

I also noticed that you have depricated
org.powermock.api.mockito.powermocklistener.AnnotationEnabler and
org.powermock.core.classloader.annotations.Mock. I retested the attached 
examples
without the @PowerMockListener and with the org.mockito.Mock instead, and the 
test
succeeds just as well. :-)

Original comment by mat...@gmail.com on 9 Oct 2009 at 11:31

GoogleCodeExporter commented 9 years ago
Great! :)

Original comment by johan.ha...@gmail.com on 9 Oct 2009 at 1:54