ssacher-tgm / mockito

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

MockitoJUnitRunner misreports JUnit method type error #142

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using the MockitoJUnitRunner to execute a JUnit test case, it appears
to capture certain JUnit errors and instead reports that "MockitoRunner can
only be used with JUnit 4.4 or higher", even when using a valid version.

For example (and this is how I stumbled on the problem), methods marked
with a @BeforeClass annotation must be declared static. Forgetting to do
this normally results in an error from JUnit: "Method xxx() should be
static". But the MockitoJUnitRunner catches this error and reports a
misleading and entirely incorrect error instead.

I have tested this with Mockito 1.8.0 and JUnit 4.5. The attached file
demonstrates the incorrect error. Comment out the @RunWith line to see the
correct error.

Original issue reported on code.google.com by mhack...@kanayo.com on 9 Nov 2009 at 6:12

Attachments:

GoogleCodeExporter commented 8 years ago
P.S. It looks like org.mockito.internal.runners.RunnerFactory#create() is the
culprit. It needs to be a bit more particular about the exceptions it catches 
and
allow the underlying exception to pass through if it's not a JUnit 
version-related error.

Original comment by mhack...@kanayo.com on 9 Nov 2009 at 6:15

GoogleCodeExporter commented 8 years ago
Hey!

Thanks for reporting. I think I fixed it already in trunk - let me have a 
look...

Original comment by szcze...@gmail.com on 9 Nov 2009 at 8:56

GoogleCodeExporter commented 8 years ago
Yes, it looks like the class has been rewritten. My mistake for not checking. 
Well,
at least now you have an issue number to refer to in the release notes for 
1.8.1. :-)

Original comment by mhack...@kanayo.com on 9 Nov 2009 at 9:45

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1673.

Original comment by szcze...@gmail.com on 9 Nov 2009 at 10:03

GoogleCodeExporter commented 8 years ago
Actually, I didn't have handling for your case so I added it :) Basically I'm
forwarding jUnit exceptions now so it should be good for all other cases! 
Thanks for
reporting.

Original comment by szcze...@gmail.com on 9 Nov 2009 at 10:04

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 11 Nov 2009 at 1:33