La tâche
JUnit
Tâches de gestion de projet avancés
Installation
◮
Récupérer JUnit.jar
http://www.junit.org/
◮ export CLASSPATH=
CLASSPATH
:
APPLI/JUnit/junit-4.4.jar
Description des tâches
<junit>
This task runs tests from the JUnit testing framework
<formater>
print results of tests in different formats ( plain, xml
)
<test>
Defines a single test class
<batchtest>
Define a number of tests based on pattern matching http://ant.apache.org/manual/OptionalTasks/junit.html
39
Tâches de gestion de projet avancés
La tâche
JUnit
build.junit.xml
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement location="${build.tests}"/>
<pathelement path="${java.class.path}"/>
</classpath>
<formatter type="plain"/>
<test name="my.test.TestCase" haltonfailure="no" outfile="result">
<formatter type="xml"/>
</test>
<batchtest fork="yes" todir="${reports.tests}">
<fileset dir="${src.tests}">
<include name="**/*Test*.java"/>
<exclude name="**/AllTests.java"/>
</fileset>
</batchtest>
</junit>
printsummary
Print one-line statistics for each testcase.
fork
Run the tests in a separate VM.
haltonfailure
Stop the build process if a test fails
timeout
Cancel the individual tests if they don’t finish in the given time
todir
Directory to write the reports to
40
La tâche
svn
Tâches de gestion de projet avancés
Installation
◮
Récupérer svnant.jar, svnClientAdapter.jar et svnjavahl.jar
à partir de l’archive svnant http://subclipse.tigris.org/svnant.html
◮ Les mettre dans le classpath...
Description de la tâche svn
◮ http://subclipse.tigris.org/svnant/svn.html
◮
Exemple de build.xml mettant en oeuvre svnant dans l’archive récupérée ci-dessus
◮
Autres exemples d’utilisation subversion.open.collab.net/articles/
IntegratingSubversionIntoYourAntBuild.html
41
Tâches de gestion de projet avancés
La tâche
svn
Un exemple de
build.properties
# build.properties
svnant.version=1.0.0
lib.dir=lib svnant.jar=${lib.dir}/svnant.jar
svnClientAdapter.jar=${lib.dir}/svnClientAdapter.jar
svnjavahl.jar=${lib.dir}/svnjavahl.jar
svnant.latest.url=http://subclipse.tigris.org/svn/subclipse/trunk/svnant/ svnant.this.url=http://subclipse.tigris.org/svn/subclipse/tags/svnant/${svnant.v
ersion}/ svnant.repository.user=guest svnant.repository.passwd=""
build.xml (part 1/2)
<!-all properties are in build.properties -->
<property file="build.properties" />
<!-- path to the svnant libraries. Usually in ANT_HOME/lib -->
<path id="project.classpath">
<pathelement location="${svnjavahl.jar}" />
<pathelement location="${svnant.jar}" />
<pathelement location="${svnClientAdapter.jar}" />
</path>
...
42
Tâches de gestion de projet avancés
La tâche
svn
build.xml (part 2/2)
...
<!-- load the svn task -->
<taskdef resource="svntask.properties" classpathref="project.classpath"/>
<target name="clean">
<delete dir="src_latest"/>
<delete dir="src_${svnant.version}"/>
</target>
<target name="checkoutLatest">
<svn username="${svnant.repository.user}" password="${svnant.repository.pass
wd}">
<checkout url="${svnant.latest.url}" revision="HEAD" destPath="src_latest"
/>
</svn>
</target>
<target name="checkoutThis">
<svn username="${svnant.repository.user}" password="${svnant.repository.pass
wd}">
<checkout url="${svnant.this.url}" revision="HEAD" destPath="src_${svnant.
version}" />
</svn>
</target>
43
La classe implémentant cette tâche
Code de la classe implémentant la tâche
Définir ses propres tâches – Sommaire
Définir une tâche ant dans le build.xml
La classe implémentant cette tâche
Code de la classe implémentant la tâche
44

Public link updated
The public link to your chat has been updated.