We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4
Spring Boot Applicatio
Service Layer Testing
By Ramesh Fadatare (Java Guides)
Spring Boot Application
Service Layer Testing
Controller Service Repository
DB Layer Layer Layer
Mockito
Service Layer Testin
1.Create EmployeeService with saveEmployee method 2.Quick Recap of Mockito basics (before writing Unit tests) 3.Unit test for EmployeeService saveEmployee method 4.Using @Mock and @InjectMocks annotations to mock the object 5.Unit test for saveEmployee method which throws Exception 6.Unit test for EmployeeService getAllEmployees method - Positive Scenario 7.Unit test for EmployeeService getAllEmployees method - Negative Scenario 8.Unit test for EmployeeService getEmployeeById method 9.Unit test for EmployeeService updateEmployee method 10.Unit test for EmployeeService deleteEmployee method g
JUnit tests in BDD Style
Syntax Example
@Test public void given_when_then() { // given - precondition or setup