tiebin-zhang / powermock

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

Spying wipes out spied object's collaborators #263

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Create a real instance of an of an object with collaborators 
2.  Create a spied-version using PowerMockito.spy()
3.  Dereferencing the collaborator results in a NullPointerException

What is the expected output? What do you see instead?
Normal behavior interrupted by NullPointerException

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

Please provide any additional information below.
This issue was discussed in the user group.  Please see http://is.gd/cVZ37.

Here is short experiment that details the problem:

@Test public void experiment() { 
  MyService service = new MyService(); 
  MyService mockitoSpy = Mockito.spy(service); 
  MyService powermockSpy = PowerMockito.spy(service); 
  System.out.println("Mockito:" + ((mockitoSpy .getMyDao() != null) ? 
"non null" : "null")); 
  System.out.println("Powermock:" + ((powermockSpy .getMyDao() != 
null) ? "non null" : "null")); 
} 

Original issue reported on code.google.com by srivaths.sankaran on 20 Jun 2010 at 3:20

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 14 Jul 2010 at 12:16

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 14 Jul 2010 at 12:16

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 14 Jul 2010 at 2:58