samedi 23 juillet 2016

Uses of Mockit.reset() on a mock object while writing test

Is it right to use Mockito.reset() in @Before method for mock objects which is being used in more than test method in the same test Class as shown below.

public class SampleTest {   

  @Mock
  private CustomRepository customRepo;

  @Before
  public void setUp() {
    Mockito.reset(customRepo);
  }

  @Test
  public void test1(){
  ......

  given(customRepo.someMethod()).willReturn(Answer1);
  ......
  }

  @Test
  public void test2(){
  ......

  given(customRepo.someMethod()).willReturn(Answer2);
  ......
  }

}

Aucun commentaire:

Enregistrer un commentaire