Write test cases class for testing. We will be using JUnit for this purpose.
package com.javabykiran;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
@Autowired
EmployeeDao employeeDao;
@Test
public void contextLoads() {
employeeDao.employeeOperation(new Employee(19,"kiran19"));
}
@Test
public void loadEmployeeList() {
List<Employee> listEmp= employeeDao.getEmployee(13);
System.out.println(listEmp.size());
}
@Test
public void loadEmployeeById() {
Employee emp= employeeDao.getEmployeeById(13);
System.out.println(emp);
}
}
We can see result in JUnit window as below.