SE450: JUnit: Integrating with Ant [40/41] ![]() ![]() ![]() |
.jar files - put junit.jar in both your own lib directory, and
%ANT_HOME%\lib
.
build.xml changes - pay attention to the compiletests, test,
and alltests
tasks.
compiletests
task will first compile your own
code, then compile the tests for your code. If you aren't using
ant, you need to make sure you do both of these steps manually.test
task will run one test and print a plain summary to the
testresults folderalltests
task will find all classes with the
name pattern of *Test and run them all at once. It will print
the results to a testresult file - one per Test class.A test result file looks like this:
TEST-se450.mwright1.junit.VectorTest.txt Testsuite: se450.mwright1.junit.VectorTest Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.02 sec Testcase: testCapacity took 0.01 sec Testcase: testContains took 0 sec Testcase: testElementAt took 0 sec
compiling tests - run the compiletests task in Ant, or use javac like before but with the junit.jar file in your classpath.
run tests using either:
junit.textui.TestRunner
junit.awtui.TestRunner
junit.swingui.TestRunner
Both of the ant tasks use a version of junit.textui.TestRunner