[JUnit 4, Ant 1.7] assertEquals et assertTrue undefined
Bonjour,
mon environnement est le suivant :
Junit 4.0
Ant 1.7
Eclipse 3.3
Java 1.5
J'essaie de faire tourner un test JUnit sous Eclipse mais je rencontre un problème de compilation (tout bête j'imagine) :
Code:
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
|
package entity;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.log4j.BasicConfigurator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class PersonTest {
private final Person p1 = new Person("Brett", 'L', "Schuchert", "Street1",
"Street2", "City", "State", "Zip");
private EntityManagerFactory emf;
private EntityManager em;
@Before
public void initEmfAndEm() {
BasicConfigurator.configure();
emf = Persistence.createEntityManagerFactory("examplePersistenceUnit");
em = emf.createEntityManager();
}
@After
public void cleanup() {
em.close();
}
@SuppressWarnings("unchecked")
@Test
public void insertAndRetrieve() {
em.getTransaction().begin();
em.persist(p1);
em.persist(p2);
em.getTransaction().commit();
final List<Person> list = em.createQuery("select p from Person p")
.getResultList();
assertEquals(2, list.size());
for (Person current : list) {
final String firstName = current.getFirstName();
assertTrue(firstName.equals("Brett") || firstName.equals("FirstName"));
}
}
} |
The method assertEquals(int, int) is undefined for the type PersonTest
et
The method assertTrue(boolean) is undefined for the type PersonTest
Si j'importe junit.framework.TestCase et que j'étends la classe de TestCase :
Code:
1 2
|
public class PersonTest extends TestCase { |
ça compile mais je suis plus en JUnit version 4 du coup.
Et de toute façon le test plante en me disant qu'il ne trouve pas de méthodes de test ...
Y a t-il un problème de compatibilité dans les versions que j'utilise ?
(ant, eclipse, junit ...)
Merci d'avance pour votre aide.