Closed GoogleCodeExporter closed 9 years ago
Original comment by brice.du...@gmail.com
on 13 May 2011 at 2:13
Here's an example of what this feature could allow.
Suppose we have the following classes :
public static class AntiCorruptionValidator {
private PartOfTheDomain diff;
private PartOfTheDomain original;
//...
}
public static class PartOfTheDomain {
public boolean applyDiff(PartOfTheDomain diff) {
return false;
}
}
In the test we could write this :
@RunWith(MockitoJUnitRunner.class)
public class AntiCorruptionValidatorTest {
private PartOfTheDomain diff = mock(PartOfTheDomain.class, withSettings().serializable());
private PartOfTheDomain original = when(mock(PartOfTheDomain.class).applyDiff(any(PartOfTheDomain.class))).thenReturn(true).getMock();
@InjectMocks
private AntiCorruptionValidator antiCorruption;
@Test
public void some_test_implying_diff_and_original() throws Exception {
antiCorruption.applyIfOk();
verify(original).applyDiff(same(diff));
}
}
In other word, Mockito will detect mocks in fields and try to inject them if
possible.
Original comment by brice.du...@gmail.com
on 28 Oct 2011 at 2:06
Original comment by brice.du...@gmail.com
on 28 Oct 2011 at 5:20
Original comment by szcze...@gmail.com
on 13 May 2012 at 3:37
Original comment by szcze...@gmail.com
on 3 Jun 2012 at 2:06
Original comment by brice.du...@gmail.com
on 3 Sep 2012 at 10:00
Original issue reported on code.google.com by
brice.du...@gmail.com
on 13 May 2011 at 2:13