Monday, 30 March 2015

Solution :ant build successful even if some testng tests failed

ant build successful even if some testng tests failed

Some time you might have seen that even though your testNG test is failing but still ant shows it as build successful.
If you want to make your build run as failed if any of TestNG tests fails, then you need to add following testNG failure property in your build.xml


<target name="seleniumTestNG" >
                <testng outputdir="${testoutput}" classpathref="classpath.test" failureProperty="testFailed">    </testng>
  <fail if="testFailed" message="A test has failed, Please check the logs" />
 </target>

After adding the above lines in build.xml, run you scripts, now you will see if your test fails it will show build failed with message "A test has failed, Please check the logs"




6 comments: