Bonjour à tous,

j'essaye d'intégrer l'exécution de mes tests dans un script Ant mais je rencontre quelques soucis. En effet, lors de l'exécution du test, j'obtiens l'erreur suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
[junit] Running TestFenetre
[junit] Testsuite: TestFenetre
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Testcase: initializationError took 0 sec
Et voici mon script Ant :

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
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<project name="TestAnt1" default="all">
  <description>
   Test ANT avec JUnit
  </description>
 
  <property name="bin" location="."/>
  <property name="src" location="."/>
  <property name="build" location="build"/>
  <property name="doc" location="${build}/doc"/>
  <property name="lib" location="${build}/lib"/>
  <property name="junit_path" value="D:/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
  <property name="junit3_path" value="D:/eclipse/plugins/org.junit_3.8.2.v3_8_2_v20100427-1100/junit.jar"/>	
  <property name="fixture_path" value="D:/Documents and Settings/fest-swing-1.2/fest-swing-1.2/fest-swing-1.2.jar"/>
  <property name="hamrect" value="D:/eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>	
 
  <target name="compil"  description="Compilation">
    <javac srcdir="${src}" destdir="${bin}"> 
          <classpath>
        <pathelement location="${junit_path}"/>
        <!--pathelement location="${hamrect_path}"/-->
        <pathelement location="${fixture_path}"/>
      </classpath>
    </javac>
  </target>
 
  <target name="test" depends="compil" description="Executer tests avec JUnit">
    <junit fork="yes" haltonerror="true" printsummary="on">
      <classpath>
        <pathelement location="${bin}"/>
      	<pathelement location="${junit_path}"/>
      </classpath>
      <formatter type="plain" usefile="false" />
      <test name="TestFenetre"/>
    </junit>
  </target>
 
   <target name="all" depends="compil, test"  description="Generation complete">
	    <echo message="Compilation + Test OK."/>
  </target>
 
</project>
En regardant sur le net, j'ai vu que celà pouvait être du à mon junit spécifié dans le classpath. J'ai essayé avec un jar pour JUnit3 et j'obtiens

[junit] No tests found in TestFenetre

ce qui correspond au même résultat que si j'exécute "à la main" mon test avec JUnit3.

Si je ne spécifie pas JUnit dans mon classpath, alors il me retourne l'erreur

The <classpath> for <junit> must include junit.jar if not in Ant's own classpath

Je ne comprends d'où vient cette erreur, je jar que je spécifie dans le classpath est bien celui utilisé pour exécuter JUnit "à la main" (et là ça fonctionne).

Merci d'avance