[Lancement junit + report FAIL]
Bonjour,
J'ai un projet ou je voudrai faire des tests unitaire via une tache ant et par la même lancer la génération d'un rapport de test.
Hors j'ain un message d'erreur suivant :
Citation:
BUILD FAILED: C:\eclipse\workspace\monprojet\build\build.xml:136: The following error occurred while executing this line:
C:\eclipse\workspace\monprojet\build\build.xml:100: Could not create task or type of type: junit.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'junit'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use
Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath
Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
Je sais vous allez qu'il à déja des nouvelles à ce sujet. En fait je les ai parcouru en suivant leurs contenu.
J'ai rajouter un junit.jar dans le même répertoire que mon ant, mais rien n'y fait et redémarré Eclipse
je vous joint mon build.xml.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
<project name="monprojet" default="run" basedir="..">
<!-- Permet de recuperer la getion du temps -->
<tstamp/>
<!-- Declaration des variables du projet ant -->
<property environment="myenv"/>
<property name="description.jar" value="JAR des classes de ${ant.project.name}"/>
<property name="app.name" value="${ant.project.name}"/>
<property name="debug.dir" value="false"/>
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
<property name="doc.dir" value="documentation"/>
<property name="distribution.dir" value="deploiement"/>
<property name="lib.dir" value="lib"/>
<property name="test.reports" value="junit"/>
<property name="version.module" value="1.0"/>
<property name="jarFile" value="${app.name}-${version.module}.jar"/>
<property name="test.reports" value="junit"/>
<property name="log4j.properties" value="log4j.properties"/>
<!-- Ne pas oublier de rajouter la variable d'environnement
JUNIT_HOME sur le poste local -->
<property name="common_lib" value="${myenv.JUNIT_HOME}"/>
<!-- fichiers jar necessaires -->
<property name="log4j" value="${lib.dir}/log4j-1.2.13.jar" />
<property name="xercesImpl" value="${lib.dir}/xercesImpl.jar" />
<property name="xmlParser" value="${lib.dir}/xml-apis.jar" />
<property name="junit.jar" value="${common_lib}/junit.jar"/>
<!-- classpath necessaire a la compilation -->
<path id="classpath">
<pathelement location="${classes}" />
<pathelement location="${log4j}" />
<pathelement location="${xercesImpl}" />
<pathelement location="${xmlParser}" />
<pathelement path="${junit.jar}"/>
</path>
<!-- Tache d'initialisation du projet ant -->
<target name="init" description="Initialisation du projet" depends="clean">
<mkdir dir="${classes.dir}" />
<mkdir dir="${doc.dir}" />
<mkdir dir="${distribution.dir}" />
<mkdir dir="${test.reports}" />
</target>
<!-- Tache permettant de compiler les sources du projet -->
<target name="compile" depends="init" description="Compilation des sources">
<javac srcdir="${src.dir}" destdir="${classes.dir}" excludes="monprojet/TestUnitaire/**" classpathref="classpath" />
<copy file="${src.dir}/log4j.properties" tofile="${classes.dir}/log4j.properties"/>
</target>
<!-- Tache permettant de generer la documentation javadoc du projet developpement-->
<target name="documentation-devel" description="Generation de la documentation">
<javadoc destdir="${doc.dir}" excludepackagenames="monprojet.TestUnitaire" access="public" source="1.5" use="true" notree="false" nonavbar="false" noindex="false" splitindex="true" author="true" version="true" nodeprecatedlist="false" nodeprecated="false" packagenames="*" sourcepath="${src.dir}" doctitle="monprojet" classpathref="classpath"/>
</target>
<!-- Tache permettant de generer la documentation javadoc du projet de livraison-->
<target name="documentation-livraison" description="Generation de la documentation">
<javadoc destdir="${doc.dir}" access="public" source="1.5" use="true" notree="false" nonavbar="false" noindex="false" splitindex="true" author="true" version="true" nodeprecatedlist="false" nodeprecated="false" packagenames="monprojet.Traitement" sourcepath="${src.dir}" doctitle="monprojet" classpathref="classpath"/>
</target>
<!-- Tache permettant de generer le fichier jar projet -->
<target name="distribution" depends="compile" description="Generation de l'archive jar file">
<jar jarfile="${distribution.dir}/${jarFile}" >
<fileset dir="${classes.dir}">
<include name="**/*.*"/>
<exclude name="**/TestUnitaire/Test*.java"/>
</fileset>
<fileset dir="${src.dir}">
<include name="META-INF/**/*.*"/>
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<section name="${app.name}">
<attribute name="Specification-Title" value="${description.jar}"/>
<attribute name="Specification-Version" value="${version.module}"/>
<attribute name="Specification-Vendor" value="monprojet"/>
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Implementation-Version" value="${version.module} ${TODAY}"/>
<attribute name="Implementation-Vendor" value="monprojet"/>
</section>
</manifest>
</jar>
</target>
<target name="junit" depends="compile" description="junit + report">
<delete dir="${test.reports}/fr"/>
<delete>
<fileset dir="${test.reports}" includes="*.*"/>
</delete>
<junit fork="yes" printsummary="yes" haltonfailure="no">
<sysproperty key="java.naming.provider.url" value="${providerurl}"/>
<sysproperty key="java.naming.factory.initial" value="${factoryinitial}"/>
<sysproperty key="log4j.configuration" value="${log4j.properties}"/>
<batchtest fork="yes" todir="${test.reports}" >
<fileset dir="${classes.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="classpath" />
</junit>
<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reports}" />
</junitreport>
</target>
<!-- Tache permettant de supprimer les repertoires du projet -->
<target name="clean" description="Nettoyage du projet">
<delete dir="${classes.dir}"/>
<delete dir="${doc.dir}"/>
<delete dir="${distribution.dir}"/>
</target>
<!-- Tache permettant de lancer des tests unitaires -->
<target name="run.test" description="Lancement des tests unitaires">
<antcall target="junit"/>
<antcall target="clean"/>
<echo message="Tests executes. Resulats dans ${test.reports}"/>
</target>
<!-- Tache permettant de lancer toutes les taches du projet -->
<target name="run" description="Lancement de l'ensemble des taches du projet" depends="init,compile,documentation-devel,documentation-livraison">
</target>
</project> |
Auriez vous un idées du problème ?
Cordialement,
xarius