java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow
So I would recommend the use of the
MockitoJUnitRunner
wherever possible. However, as Tomasz Nurkiewicz has correctly pointed out, you can't use it if you need another JUnit runner, such as the Spring one.
My recommendation has now changed. The Mockito team have added a new feature since I first wrote this answer. It's a JUnit rule, which performs exactly the same function as the MockitoJUnitRunner
. But it's better, because it doesn't preclude the use of other runners.
Read full article from java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow
No comments:
Post a Comment