@RunWith(PowerMockRunner.class) vs @RunWith(MockitoJUnitRunner.class)
在通常的 mocking with 和 annotations 中,所测试的类应与 一起运行。@Mock@InjectMocks@RunWith(MockitoJUnitRunner.class)
@RunWith(MockitoJUnitRunner.class)
public class ReportServiceImplTestMockito {
     @Mock 
     private TaskService      mockTaskService;
     @InjectMocks 
     private ReportServiceImpl service;
         // Some tests
}
但是在一些例子中,我看到被使用:@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
  }
}
有人可以指出它有什么区别,以及我想使用一个而不是另一个吗?
 
					 
				 
				    		 
				    		 
				    		 
				    		