Merge pull request #4738 from priyeshmashelkar/master
BAEL-1907 Renamed test methods to follow BDD style
This commit is contained in:
commit
ac245f16e0
|
@ -15,18 +15,22 @@ public class MockAnnotationUnitTest {
|
|||
UserRepository mockRepository;
|
||||
|
||||
@Test
|
||||
public void testMockAnnotation() {
|
||||
public void givenCountMethodMocked_WhenCountInvoked_ThenMockValueReturned() {
|
||||
Mockito.when(mockRepository.count()).thenReturn(123L);
|
||||
|
||||
long userCount = mockRepository.count();
|
||||
|
||||
Assert.assertEquals(123L, userCount);
|
||||
Mockito.verify(mockRepository).count();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMockitoMockMethod() {
|
||||
public void givenCountMethodOfLocalMockVariableMocked_WhenCountInvoked_ThenMockedValueReturned() {
|
||||
UserRepository localMockRepository = Mockito.mock(UserRepository.class);
|
||||
Mockito.when(localMockRepository.count()).thenReturn(111L);
|
||||
|
||||
long userCount = localMockRepository.count();
|
||||
|
||||
Assert.assertEquals(111L, userCount);
|
||||
Mockito.verify(localMockRepository).count();
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ public class MockBeanAnnotationIntegrationTest {
|
|||
ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testMockBean() {
|
||||
public void givenCountMethodMocked_WhenCountInvokedOnBeanFromContext_ThenMockValueReturned() {
|
||||
Mockito.when(mockRepository.count()).thenReturn(123L);
|
||||
|
||||
UserRepository userRepoFromContext = context.getBean(UserRepository.class);
|
||||
long userCount = userRepoFromContext.count();
|
||||
|
||||
Assert.assertEquals(123L, userCount);
|
||||
Mockito.verify(mockRepository).count();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue