Hi, in this case I would recommend you to use Groovy and its AntBuilder. Otherwise the syntax would be to cumbersome and you have to be really careful to configure your Task instances the way Ant does it (for instance in your example you forgot to set the project on some tasks, to set the owning target and you called execute() whereas you should call perform())
Marc. -- Blog: http://mguillem.wordpress.com Subir Bhaumik wrote: > > Hi Andrew, > Thanks for your quick reply. Actually i have already tested our > application writing build.xml. But i want to run those scripts writing > java code using ant and canoo webtest api. The code will take the > webtest script(only the test script excluding the ant tasks or ant > properties) as input and run that using ant programmatically. > > Ihave tried like below: > > Project p2 = new Project(); > p2.setName("webtest_proj"); > p2.setDefault("web_test_task") ; > p2.setBasedir("."); > > Configuration config = new Configuration(); > config.setHaltonerror(false); > config.setHaltonfailure(false); > config.setHost("localhost"); > config.setPort(8080); > config.setProtocol("http"); > config.setResultfile("results.xml"); > config.setResultpath(new > File("D:\\subir\\Downloads\\webtest")); > config.setSaveresponse(true); > config.setSummary(true); > > Ant ant = new Ant(); > //ant.setProject(p2); > ant.setTaskName("test"); > > ant.setAntfile("D:\\subir\\Downloads\\webtest\\bkmmodulemod.xml"); > WebtestTask webtask = new WebtestTask(); > webtask.setProject(p2); > webtask.setName("web_test_task"); > webtask.setTaskName("web_test_task"); > webtask.addConfig(config); > webtask.addTask(ant); > > Target web_test_task = new Target(); > web_test_task.setName("web_test_task"); > web_test_task.addTask(webtask); > > web_test_task.execute(); > p2.addTarget(web_test_task); > > > Thanks > > Subir > > On Tue, 11 Sep 2007 Andrew Sickorsky wrote : >>Hello, Subir! >>in our company we used the following: >>part of build.xml: >><target name="test-web"> >> <taskdef > file="${test-web.dir}/properties/webtest-tasks.properties"> >> <classpath refid="compile.test.classpath"/> >> </taskdef> >> <ant antfile="${test-web.dir}/use-cases/web-tests.xml"/> >> </target> >> >>where web-test.xml is a common Canoo WebTest's file, and > compile.test.classpath is ANT path structure with reference to directory > with Webtest's library JARs (in our case they are: >>activation-1.1.jar >>classpath.xml >>commons-httpclient-3.0.1.jar >>commons-io-1.3.1.jar >>dom4j-1.6.1.jar >>fontbox-0.1.0-dev-patched-20060622.jar >>groovy-all-1.0.jar >>htmlunit-1.13.jar >>jaxen-1.1.1.jar >>js-1.6R5.jar >>mail-1.4.jar >>nekohtml-0.9.5.jar >>oro-2.0.6.jar >>pdfbox-0.7.3-dev-log4j-20060612.jar >>poi-3.0.1-FINAL.jar >>webtest.jar >>2webtest_T.jar) >> >>may be this helps. >> >>Cheers, >>Andrew >>> >>> Hi, >>>I'm using Canoo WebTest tool for automated testing of our application. > I have already tested our application using this tool running the script > from command line. >>> >>>Now, i want to run test writing java code using ant and canoo webtest > api taking the test script file as input. >>> >>>Can anybody provide me sample code to start with for that or any > reference. >>> >>>Help me Please...... >>> >>>Thanks && Regards............... >>> >>>Subir >>> >>> >>> >>>travel_rediff_signature_578x38.jpg > <http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/[EMAIL > > PROTECTED]/1436607_1430041/1436150/1?PARTNER=3&OAS_QUERY=null%20target=new%20> > >>> >> > > > > sbi_rediff_signatureline_578x38.jpg > <http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/[EMAIL > PROTECTED]/1436607_1430041/1436146/1?PARTNER=3&OAS_QUERY=null > target=new > > _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

