bonjour;
j'ai reçue cet erreur lorsque j'essaye de lancé les tests unitaires, mon test unitaire vérifie est ce que ma list contient des enregistrements, voila mon test et ma classe service avec l'erreur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.service;
 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.myapp.course.Course;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.*;
import static org.junit.Assert.*;
 
/**
 *
 * @author nadya
 */
public class CourseServiceImplTest {
 
    public static ClassPathXmlApplicationContext context;
    public static CourseService courseService;
 
    public CourseServiceImplTest() {
    }
 
    @BeforeClass
    public static void setUpClass() throws Exception {
        context = new ClassPathXmlApplicationContext("application-context.xml");
        courseService = (CourseService) context.getBean("courseService");
    }
 
    @AfterClass
    public static void tearDownClass() throws Exception {
        context.close();
    }
 
    @Before
    public void setUp() {
    }
 
    @After
    public void tearDown() {
    }
 
    /**
     * Test of findAll method, of class CourseServiceImpl.
     */
    @Test
    public void testFindAll() {
        List<Course> allCourses=courseService.findAll();
        assertNotNull(allCourses);
        assertTrue(allCourses.size()>0);
    }
}
ma classe service:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.service;
 
import com.myapp.course.Course;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
/**
 *
 * @author nadya
 */
@Service("courseService")
@Transactional
public class CourseServiceImpl implements CourseService {
 
    @Autowired
    private SessionFactory sessionFactory;
 
    @Override
    public List<Course> findAll() {
       return sessionFactory.getCurrentSession().createQuery("from Course").list();
    }  
}
et voila mon erreur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
--com.myapp.service.CourseServiceTest FAILED
     ----testFindAll FAILED: jUnit.framework.AssertionFailedError
           ------ junit.framework.assertionFailedError
           ------ at com.myapp.service.ServiceCourseImplTest.testFindAll(CourseServiceImplTest.java)
merci d'avance!