> From: Stefan Bodewig [mailto:[EMAIL PROTECTED] > > The other part will be an <antunit> task, which will take a build file > and for each target whose name starts with "test" will > > (1) create an Ant task > (2) run the target named setUp if present > (3) run the target > (4) run the target named tearDown if present
(2) mimicks JUnit, but may not be necessary. I've found personally that Ant's depends="setUp" attribute on target is enough, and more flexible when you want to customize the test fixture using several setup targets. (4) OTOH is useful and great for cleanup directly from Ant. I use a modified BuildFileTest adapted to call any 'tearDown' target. /** * Automatically configures the project, inferring the build file to * use from the current test case class name. * * @throws Exception if a Ant build file named after this test case * (with the .xml suffix) cannot be found collocated to that * test case' class file. */ protected void setUp() throws Exception { String classname = getClass().getName(); String resname = '/' + classname.replace('.', '/') + ".xml"; URL buildfileURL = getClass().getResource(resname); File buildfile = new File(new URI(buildfileURL.toString())); configureProject(buildfile.getAbsolutePath()); _buildfile = buildfile; } /** * Automatically calls the target called "tearDown" * from the build file tested if it exits. */ protected void tearDown() { final String tearDown = "tearDown"; if (project.getTargets().containsKey(tearDown)) { project.executeTarget(tearDown); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]