示例#1
0
 @Test
 public void testGetValue() {
   int param = 10;
   int mockedValue = 25;
   // mock void method
   valueRepository.reset();
   EasyMock.expectLastCall();
   // mock method with returning value
   EasyMock.expect(valueRepository.get(param)).andReturn(mockedValue);
   EasyMock.replay(valueRepository);
   int result = showcase.getValue(param);
   assertEquals(mockedValue + 10, result);
   EasyMock.verify(valueRepository);
 }
示例#2
0
 @Test
 public void testGetValue() {
   int param = 10;
   int mockedValue = 25;
   // mock void method
   Mockito.doNothing().when(valueRepository).reset();
   // mock method with returning value
   Mockito.when(valueRepository.get(param)).thenReturn(mockedValue);
   int result = showcase.getValue(param);
   assertEquals(mockedValue + 10, result);
   Mockito.verify(valueRepository);
 }