Je voudrais exécuter des tests junit5 en combinaison avec ant, plus précisément junitlauncher
Voici la structure de mon projet :
et voici mon fichier de construction :
<?xml version="1.0" encoding="UTF-8"?>
<project default="test" name="test">
<property name="src.dir" value="${basedir}/src" />
<property name="output.dir" value="${basedir}/build" />
<!-- PATH DEFINITIONS -->
<path id="junit5.classpath">
<fileset dir="${basedir}/lib/" />
</path>
<path id="test.classpath">
<path refid="junit5.classpath" />
<fileset dir="${output.dir}">
<include name="**/*.class" />
</fileset>
</path>
<target name="clean">
<delete dir="${output.dir}" />
</target>
<target name="compile" depends="clean">
<mkdir dir="${output.dir}" />
<mkdir dir="${output.dir}/report" />
<javac srcdir="${src.dir}" destdir="${output.dir}" includeantruntime="false">
<!-- test libs -->
<classpath>
<path refid="junit5.classpath" />
</classpath>
</javac>
</target>
<target name="test" depends="compile">
<pathconvert property="classpathProp" refid="test.classpath"/>
<echo>Classpath is ${classpathProp}</echo>
<echo>Running junit tests...</echo>
<junitlauncher>
<classpath refid="test.classpath" />
<test name="test.SomeClassTest" />
</junitlauncher>
</target>
</project>
Quand j'essaie d'exécuter la tâche de test, je peux voir le classpath :
Classpath is
/Users/some-username/Documents/workspace/test/lib/junit-jupiter-api-5.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-jupiter-engine-5.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-jupiter-migrationsupport-5.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-jupiter-params-5.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-platform-commons-1.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-platform-engine-1.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-platform-launcher-1.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-platform-runner-1.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-platform-suite-api-1.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit-vintage-engine-5.3.0-SNAPSHOT.jar:
/Users/some-username/Documents/workspace/test/lib/junit.jar:
/Users/some-username/Documents/workspace/test/lib/org.apiguardian_1.0.0.v20180327-1502.jar:
/Users/some-username/Documents/workspace/test/lib/org.hamcrest.core_1.3.0.v20180420-1519.jar:
/Users/some-username/Documents/workspace/test/lib/org.opentest4j_1.0.0.v20180327-1502.jar:
/Users/some-username/Documents/workspace/test/build/test/SomeClass.class:
/Users/some-username/Documents/workspace/test/build/test/SomeClassTest.class:
/Users/some-username/Documents/workspace/test/build/test/TestSuite.class
suivi par :
ÉCHEC DE LA CONSTRUCTION /Users/some-username/Documents/workspace/test/build.xml:36 : java.lang.NoClassDefFoundError : org/junit/platform/launcher/core/LauncherFactory
vous pouvez trouver l'archive du projet eclipse ici : https://drive.google.com/file/d/161rYTopmqM3JMqv8kvM6VjJbG1sm-3k2/view?usp=sharing
Comment puis-je le faire fonctionner ? Qu'est-ce que j'ai manqué ?