home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / doc / junit4 / README.Debian < prev    next >
Encoding:
Text File  |  2010-06-22  |  1.9 KB  |  57 lines

  1. Using JUnit4 with Ant
  2. =====================
  3. One of the common use case for JUnit is using it with Ant build system,
  4. as part of the build process of your source code.
  5.  
  6.  Explanation
  7.  ------------
  8. To launch some JUnit4 TestCase from Ant, you need "ant" and "junit4" packages.
  9.  
  10. You also need to add junit4.jar in nested <classpath> of your <junit> targets.
  11. There is no need to add it in CLASSPATH or to ANT_HOME/lib [1].
  12.  
  13.   [1]
  14.   <URL:http://ant.apache.org/faq.html#delegating-classloader>
  15.   "As of Ant 1.7 <junit> no longer requires you to have junit.jar in Ant's
  16.    start-up classpath"
  17.  
  18.   <URL:http://ant.apache.org/manual/install.html#librarydependencies>
  19.   "For example, as of Ant 1.7.0 you can run the <junit>  task without junit.jar
  20.    in Ant's own classpath, so long as it is included (along with your program
  21.    and tests) in the classpath passed when running the task.
  22.    Where possible, this option is generally to be preferred, as the Ant script
  23.    itself can determine the best path to load the library from"
  24.  
  25. This strategy also prevent unwanted clash with junit 3.x : you can launch
  26. multiple junit target, each with its own classpath.
  27.  
  28. For detailed history, you could see #512530 and #543327 in Debian BTS.
  29.  
  30.  
  31.  Sample
  32.  ------
  33. Here is a Ant snippet for JUnit4 usage :
  34. ----------------------------------------------------------------
  35. <property name="main.classes" value="target/classes"/>
  36. <property name="test.classes" value="target/test-classes"/>
  37. <property name="lib.dir" value="/usr/share/java"/>
  38.  
  39. <target name="test" depends="init, compile, compile-test">
  40.  
  41.   <junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
  42.  
  43.     <classpath location="${main.classes}"/>
  44.     <classpath location="${test.classes}"/>
  45.     <classpath location="${lib.dir}/junit4.jar"/>
  46.  
  47.     <formatter type="plain" />
  48.  
  49.     <batchtest>
  50.       <fileset dir="${test.classes}" includes="**/*TestCase"/>
  51.     </batchtest>
  52.  
  53.   </junit>
  54.  
  55. </target>
  56. ----------------------------------------------------------------
  57.