Skip to content

Commit 5d87e46

Browse files
author
Swapan Pramanick
committed
BAEL-2221: using MockitoJunitRunner
1 parent dbf2721 commit 5d87e46

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎spring-resttemplate/src/test/java/org/baeldung/web/service/EmployeeServiceUnitTest.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
import org.junit.Assert;
55
import org.junit.Before;
66
import org.junit.Test;
7+
import org.junit.runner.RunWith;
78
import org.mockito.InjectMocks;
89
import org.mockito.Mock;
910
import org.mockito.Mockito;
1011
import org.mockito.MockitoAnnotations;
12+
import org.mockito.runners.MockitoJUnitRunner;
1113
import org.slf4j.Logger;
1214
import org.slf4j.LoggerFactory;
1315
import org.springframework.http.HttpStatus;
1416
import org.springframework.http.ResponseEntity;
1517
import org.springframework.web.client.RestTemplate;
1618

19+
@RunWith(MockitoJUnitRunner.class)
1720
public class EmployeeServiceUnitTest {
1821

1922
private static final Logger logger = LoggerFactory.getLogger(EmployeeServiceUnitTest.class);
@@ -24,11 +27,6 @@ public class EmployeeServiceUnitTest {
2427
@InjectMocks
2528
private EmployeeService empService = new EmployeeService();
2629

27-
@Before
28-
public void setup() {
29-
MockitoAnnotations.initMocks(this);
30-
}
31-
3230
@Test
3331
public void givenMockingIsDoneByMockito_whenGetIsCalled_shouldReturnMockedObject() throws Exception {
3432
Employee emp = new Employee("E001", "Eric Simmons");

0 commit comments

Comments
 (0)