Export to GitHub

mockito - issue #365

Provide JUnit MockitoRule as an alternative to MockitoJUnitRunner


Posted on Aug 13, 2012 by Happy Lion

Sometimes it is needed to use a particular Runner, e. g. when using the theories framework of JUnit 4 (@RunWith(Theories.class)). To still be able to use Mockito in a convenient style, it would be great to have a MockitoRule, so automatic mock injection would happen when writing code like this:

@Rule Rule useMockito = new MockitoRule();

Comment #1

Posted on Aug 13, 2012 by Happy Horse

Hi, we'll see if that happens, as we had on older JUnit in our classpath, to ensure retro-compatibility.

Thx for the idea.

Comment #2

Posted on Sep 3, 2012 by Happy Horse

(No comment was entered for this change.)

Comment #3

Posted on Feb 22, 2013 by Quick Hippo

@RunWith is broken because you can only have one @RunWith; the @Rule approach is better because you can mix multiple Rules into the same test class.

Status: Duplicate

Labels:
Type-Defect Priority-Medium Injection