Annotation @RunWith(PowerMockRunner.class) vs annotation @RunWith(MockitoJUnitRunner.class)

Comme d'habitude en se moquant avec @Mock et @InjectMocks annotations, la classe sous test doit être exécuté avec @RunWith(MockitoJUnitRunner.class).

@RunWith(MockitoJUnitRunner.class)
public class ReportServiceImplTestMockito {

     @Mock 
     private TaskService      mockTaskService;

     @InjectMocks 
     private ReportServiceImpl service;

         //Some tests
}

mais dans certains exemple que je viens de voir @RunWith(PowerMockRunner.class):

@RunWith(PowerMockRunner.class)
public class Tests {
  @Mock
  private ISomething mockedSomething;

  @Test
  public void test1() {
    //Is the value of mockedSomething here
  }

  @Test
  public void test2() {
    //Is a new value of mockedSomething here
  }
}

quelqu'un pourrait-il remarquer quoi la différence et quand je veux utiliser l'un plutôt que l'autre?

OriginalL'auteur Johan | 2016-07-08