easyforgood / mockito

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

Stack trace filtering doesn't filter dexmaker classes on Android #360

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Mockito's awesome this-is-where-you-goofed error messages pick the wrong line 
numbers on Android because stack trace filtering is cglib-specific. The message 
includes a bogus InvocationHandlerAdapter.java source:

     [exec] Error in testUnexpectedCall:
     [exec] org.mockito.exceptions.verification.NoInteractionsWanted: 
     [exec] No interactions wanted here:
     [exec] -> at com.google.dexmaker.mockitoexample.MockitoExampleActivityTest.testUnexpectedCall(MockitoExampleActivityTest.java:36)
     [exec] But found this interaction:
     [exec] -> at com.google.dexmaker.mockito.InvocationHandlerAdapter.invoke(InvocationHandlerAdapter.java:54)
     [exec] Actually, above is the only interaction with this mock.
     [exec]     at com.google.dexmaker.mockitoexample.MockitoExampleActivityTest.testUnexpectedCall(MockitoExampleActivityTest.java:36)

What we really want is the actual application code:

     [exec] Error in testUnexpectedCall:
     [exec] org.mockito.exceptions.verification.NoInteractionsWanted: 
     [exec] No interactions wanted here:
     [exec] -> at com.google.dexmaker.mockitoexample.MockitoExampleActivityTest.testUnexpectedCall(MockitoExampleActivityTest.java:36)
     [exec] But found this interaction:
     [exec] -> at com.google.dexmaker.mockitoexample.MockitoExampleActivityTest.testUnexpectedCall(MockitoExampleActivityTest.java:34)
     [exec] Actually, above is the only interaction with this mock.
     [exec]     at com.google.dexmaker.mockitoexample.MockitoExampleActivityTest.testUnexpectedCall(MockitoExampleActivityTest.java:36)

I've attached a patch that fixes stack trace filtering for Android.

Original issue reported on code.google.com by limpbizkit on 28 Jul 2012 at 6:27

GoogleCodeExporter commented 8 years ago
Attached the right patch.

Original comment by limpbizkit on 28 Jul 2012 at 6:34

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the patch!

One thing I don't like is that mockito is decoupled from dexmaker via an 
extension point but coupled with dexmaker-specific stack trace filtering logic. 
OTOH, it indeed feels low risk. I'll think about it a bit more, maybe I'll 
patch a quick plugin and push out rc-2 to test it out.

Original comment by szcze...@gmail.com on 28 Jul 2012 at 6:50

GoogleCodeExporter commented 8 years ago
Friendly ping!

Original comment by limpbizkit on 11 Sep 2012 at 9:47

GoogleCodeExporter commented 8 years ago
Hi,

Sorry we have been "busy" with summer time. Szczepan worked on something on 
that matter, you can take a look at this changeset n particular : 
http://code.google.com/p/mockito/source/detail?r=15f5c19aba7c473cf859c9cc80114dd
5547ac4f4&name=release

Original comment by brice.du...@gmail.com on 12 Sep 2012 at 8:28

GoogleCodeExporter commented 8 years ago
Totally missed that. Thanks guys.

Original comment by limpbizkit on 12 Sep 2012 at 3:13

GoogleCodeExporter commented 8 years ago
:)
If that's working for you, it will be included in the next release.

Cheers,
Brice

Original comment by brice.du...@gmail.com on 12 Sep 2012 at 3:53

GoogleCodeExporter commented 8 years ago
@limpbizkit, can you try out StackTraceCleanerProvider API and let us know if 
it would work?

Original comment by szcze...@gmail.com on 16 Sep 2012 at 10:08

GoogleCodeExporter commented 8 years ago
It works! Thanks again.
https://code.google.com/p/dexmaker/source/detail?r=e65aa027cf7bd68ec13a27e0e05d9
d8d0f03aa20

Original comment by limpbizkit on 19 Sep 2012 at 3:56

GoogleCodeExporter commented 8 years ago
Oh right :) I'll get the release going then. Thanks for feedback!

Original comment by szcze...@gmail.com on 19 Sep 2012 at 5:43

GoogleCodeExporter commented 8 years ago
Fantastic!

Original comment by limpbizkit on 19 Sep 2012 at 5:44

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 6 Oct 2012 at 8:34

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 6 Oct 2012 at 8:34

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 19 Dec 2012 at 10:59