|
Answer» Junit tests are there to check the code mainly by providing the value of any METHOD INPUT PARAMETER, how the method would work and gives the values.
public class MyEmployeeTest { ClassPathXmlApplicationContext context = NEW ClassPathXmlApplicationContext( "ApplicationContext-service.xml"); public void testMyMethod() { UserService employeeService = (UserService) context.getBean("userService"); //PROVIDE the user Id as 101581 User user = storeService.findUserByUserId(1234); //get the employee Set employee = user.getEmployeesForUserId(); System.out.println("Employee Name : "+employee.getName()); } } Junit tests are there to check the code mainly by providing the value of any method input parameter, how the method would work and gives the values. public class MyEmployeeTest { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "ApplicationContext-service.xml"); public void testMyMethod() { UserService employeeService = (UserService) context.getBean("userService"); //Provide the user Id as 101581 User user = storeService.findUserByUserId(1234); //get the employee Set employee = user.getEmployeesForUserId(); System.out.println("Employee Name : "+employee.getName()); } }
|