| Step 9: Functional tests | previous contents next |
package de.extremejava;
import de.extremejava.url.*;
public class URLParser
{
static public void main (String[] anOptArray)
throws InvalidURLException
{
URL url = URL.valueOf (anOptArray[0]);
System.out.println ("Parsing: \"" + anOptArray[0] + "\"\n");
System.out.println ("\n\nbuilt URL again as \""
+ url.toString () + "\"");
}
}
|
functionaltests. Please
change the configuration to use the JUnit text UI.functionaltests.de.extremejava.TestURLParser or copy them
from the project snapshots:
public void testRFCURL ()
throws InvalidURLException
{
URL url = URL.valueOf ("ftp://ftp.is.co.za/rfc/rfc1808.txt");
assert (url.equals (new URL ("ftp", null, null, "ftp.is.co.za", -1,
"/rfc/rfc1808.txt", null, null)));
}
|
TestPackage class in the package
functionaltests containing support for the JUnit test UI.
And now that the functional tests are written, we need to update Ant's
build.xml file and add the following target:
<target name = "functionaltests">
<java fork = "yes"
classname = "junit.textui.TestRunner"
taskname = "JUnitX"
failonerror = "true">
<arg value = "functionaltests.TestPackage" />
<classpath>
<pathelement location = "${prj.dir}/classes" />
<pathelement location = "${junit.jar}" />
<pathelement location = "${junitx.jar}" />
</classpath>
</java>
</target>
|
/home/aheilwag/java/XPTools/tools/ant/bin/ant functionaltestsjunit.textui.TestRunner as UI,
the output will look like
Buildfile: D:\shared\extreme-java\xptest-tutorial\Build.xml functionaltests: [JUnitX] ...... [JUnitX] Time: 0 [JUnitX] [JUnitX] OK (6 tests) [JUnitX] BUILD SUCCESSFUL Total time: 2 seconds |
junitx-dummy-5.0.jar or later with your application.
So that's enough of coding now, lets
see what we have achieved.
| previous contents next |
© 2001 A. Heilwagen