gordonad / powermock

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

We need a better error message when expectNew fails due to too many calls to new. #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If we do expectNew(MyClass.class) once but it's called twice we should get
a more descriptive error message than the following: 

java.lang.RuntimeException: java.lang.AssertionError: 
  Unexpected method call createInstance():
    createInstance(): expected: 1, actual: 1 (+1)
    at org.powermock.Whitebox.performMethodInvocation(Whitebox.java:788)
    at org.powermock.Whitebox.invokeMethod(Whitebox.java:268)
    at se.myapp.MyTest.testCreateDomainTarget(MyTest.java:577)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

We could perhaps catch the AssertionError in MockGateway line 117 ( return
newInvocationControl.createInstance()) and throw another AssertionError
with a better description instead.

Original issue reported on code.google.com by johan.ha...@gmail.com on 11 Sep 2008 at 8:59

GoogleCodeExporter commented 8 years ago

Original comment by johan.ha...@gmail.com on 11 Sep 2008 at 9:03

GoogleCodeExporter commented 8 years ago
Better error message when expectNew fails due to too many calls to new when a 
method
was invoked using reflection.

Original comment by johan.ha...@gmail.com on 13 Sep 2008 at 11:06