I want to execute test methods in sequence. I have used classes in testng.xml with preserve-order set to true.
<test name="group-test" preserve-order="true" >
<classes>
<class name="com.dependency.ClassA">
<methods>
<include name="create"/>
<include name="enter"/>
<include name="delete"/>
</methods>
</class>
</classes>
</test>
and my Test class is
public class ClassA {
@Test()
public void Create() throws Exception
{
System.out.println("in method create");
}
@Test(dependsOnMethods= "Create")
public void Enter() throws Exception
{
System.out.println("in method Enter");
}
@Test()
public void delete() throws Exception
{
System.out.println("in method delete");
}
After executing the test my output is
in method create,
in method delete,
in method enter
But what I want is to first execute "create" then "enter" then "delete" method. Here delete is an independent test method.
I read on a google group question where Cedric Beust mentions that you can either use dependency OR explicitly include test methods in testng.xml. I don't understand why is this an enforcement? What if I want to execute independent and dependent test methods together in any sequence I want? I have observed that independent methods get executed first and then the dependent methods.
Ideally dependency should not be for preserving order but to skip test if the previous method fails. The kind of enforcement TestNG has is causing a lot of trouble!