Wednesday, January 14, 2009

Automate your Testing using Ant Step 58

After you have created your suite of tests, you can add it to your ant script to automate it. This way after every build, your test will run and print the results.

Paste this code into your build.xml file:

<target name="test" >
<echo>Testing</echo>
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="class.path"/>
<formatter type="plain"/>
<test name="com.testing.WebTestSuite" haltonfailure="no" fork="yes" outfile="results">
<formatter type="xml"/>
</test>
</junit>
</target>

In my build.xml file I need to add the dependency to my clean target like this:

target name="clean" depends="test"


After I run my build.xml file, the test will run and print the results to the results file. If you want the build to stop building on failure, you can change haltonfailure="yes", and your build.xml file won't continue building if you test fail.

Go To Step 59

1 comments:

Azhaguvel.A October 18, 2011 2:06 AM  

Hi All,
I am new for JUnit. I have copied this sample program and run it in eclipse but browser not open.

Can anyone help me how to solve this?

Regards,
Azhaguvel.A