Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

autowire bean in junit is possible in spring

Hi,

@Test
@Autowired
StudenDao studentDao;
public void saveStudentAndCoursewithBOClass() throws Exception{
DataSend datasend = new DataSend();
Student student= new Student();
student.setEmail("new@new2223.com");
student.setFirstName("new user firstname2223");
student.setLastName("new user lastname2223");      

Course pr = new Course();
String courseName="history";
pr.setCourseName(courseName);
courseDao.save(pr);

dataFeed.saveStudentAndCourse(student, courseName);



As above junit 4 test case method when i auto wire

@Autowired
StudenDao studentDao;

Eclipse is complaining i cannot do it. Where as same auto wiring i was able to do in regular java class. Does junit test case do not allow to auto-wire the bean using annotations?

please advice
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

oh I will try that