Welcome to DeadEd.com
Sunday, May 11 2008 @ 07:07 PM CDT

JUnit

Information

JUnit is an open source Java testing framework used to write and run repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

JUnit features include:

  • Assertions for testing expected results
  • Test fixtures for sharing common test data
  • Test suites for easily organizing and running tests
  • Graphical and textual test runners

Current version in use: 3.8.1
Homepage: http://www.junit.org

Example

It runs each unit test and produces a report of the results. To use the junit target, you need to set the properties described in the Common Build Targets document.

<target name="junit"> <ant antfile="${common.build}" target="junit"> <property name="report.dir" value="C:\temp\myproject"/> <property name="test.source.dir" value="${project.root}\test"/> <property name="classes.dir" value="${project.root}\bin"/> </ant> </target> It will try to run any class that that matches *Test.java, at the same time excluding *TestCase.java and AllTests.java

The project classpath is also needed, but this is found out by the GetClasspath task. The common target will add the directory junit to the report dir you provided and create a report with the name index.html.


Last Updated Monday, November 21 2005 @ 07:36 PM CST; 1,416 Hits View Printable Version