ahmaddarawshi / powermock

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

Investigate iwhat suppression of methods returning String should return #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Since PowerMock 1.0 suppression of methods returning String returns "". Is
this really correct? Strings can be treated as Object and thus can return
null. This was the behavior in previous versions of PowerMock and this is
also the behavior when stubbing methods in Mockito. This now leads to very
strange results, e.g. let's say you have a method called A which is not
final. Stubbing this method will return null because it is not intercepted
by the MockGateway (because it's not final or static?) and goes to Mockito
directly. Changing the modifier to final will trigger the MockGateway to
intercept the call and return "" instead since the call should be suppress
when in verification mode in mockito. So the question is, should we
intercept the call to standard methods and always return "" or should we
return null? Not returning null would yeild strange results when using
PowerMockito as a substitute for Mockito. 

See SimpleStaticInitializerExample#getConcatenatedString for an example
(remove the final modifier and see how the test reacts).

Original issue reported on code.google.com by johan.ha...@gmail.com on 3 Dec 2008 at 9:23

GoogleCodeExporter commented 9 years ago
Since EasyMock also returns null for strings when using nice mock I've decided 
to go
with this approach as well in PowerMock.

Original comment by johan.ha...@gmail.com on 5 Dec 2008 at 3:12