- Your Test should extend org.junit.framework.TestCase (maybe not directly) - much more easier it would be extending org.apache.tools.ant.BuildFileTest and use a buildfile for doing the project initialization (most of the task-tests are doing that) - maybe these tutorial are interesting for you Tutorial: Writing Tasks [1] Tutorial: Tasks using Properties, Filesets & Paths [2]
Jan [1] http://ant.apache.org/manual/tutorial-writing-tasks.html#TestingTasks [2] http://cvs.apache.org/viewcvs.cgi/*checkout*/ant/docs/manual/tutorial-tasks- filesets-properties.html?content-type=text%2Fplain&rev=1.4 > -----Original Message----- > From: Le Rumeur Yves [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 05, 2004 12:02 PM > To: Mailling List Dev Ant > Subject: Example of implementation of Project from scratch > > > > hie everybody, > > I'm new in ant project, and actually i succes to > implement new ant > task, but now i want to implement unitary tess. > For this purpose, i try to simulate a creation of > project, target and > task and althought i read the different test implementation in this > project, i have trouble. > At first, i just want something very easy (see my joint code) > have you a little part of code which show how do this. > > Thanks. > > > > public class SynchroTest { > > private static File file=null; > private static Project proj=null; > > /** > * > */ > public SynchroTest() { > super(); > } > > public static void main(String[] args) { > file=new File("/home/yves/labo/legogo.txt"); > Project popo = make_project(); > System.out.println("dfaz"); > > > popo.executeTarget("taskk"); > } > > public static Project make_project(){ > Project project = new Project(); > project.init(); > project.setCoreLoader(null); > project.setName("TASKKK"); > project.setDescription("une project bidon pour > les test!"); > project.setDefault("taskk"); > project.createTask("echo"); > project.addTaskDefinition("echo",Echo.class); > project.addTarget(make_target()); > proj = project; > return project; > } > > public static Target make_target(){ > Target target = new Target(); > target.setDescription("un cible pour voir"); > target.setName("taskk"); > target.addTask(make_task(target)); > return target; > } > > public static Task make_task(Target target){ > Echo echo = new Echo(); > echo.init(); > echo.setTaskName("C UNE GROSSE TACHE"); > echo.setOwningTarget(target); > echo.setFile(file); > Echo.EchoLevel po = new Echo.EchoLevel(); > po.setValue("info"); > echo.setLevel(po); > echo.setProject(proj); > echo.setTaskName("taskk"); > echo.setMessage("WOUHOUUUUUUU"); > //echo.execute(); > return echo; > } > } > > -- > Yves > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >