0

If I have class and xml as follows :

class Test 
{

  @Test 
  public void method1() {}

  @Test (dependsOn = "method1") 
  public void method2() {}

  @Test (dependsOn = "method2") 
  public void method3() {}



  @Test (dependsOn = "method1") 
  public void otherMethod() {}

}

XML

<test name="XYZ" preserve-order="true" group-by-instances="true">
    <classes>
     <class name="Test">
      <methods>
        <include name="method1"/> 
        <include name="method2"/> 
        <include name="method3"/> 
        <include name="otherMethod"/> 
       </methods>
      </class>
     </classes>
    </test>

NOTE : Assume all methods would pass

Order of execution:

method1 > method2 > otherMethod > method3

Because method2 and otherMethod are depends on method1, they execute first and then method3 executes, although method3 is present before otherMethod in XML.

How can we execute such methods, in the sequence, we defined in XML?

Expected Order:

method1 > method2 > method3 > otherMethod

jithinkmatthew
  • 890
  • 8
  • 17
omkar
  • 1
  • 1
  • 1

1 Answers1

0

It seems otherMethod depends on method3 as strict order is required. In this case, I would recommend adding this dependency into otherMethod

@Test (dependsOnMethods  = {"method1", "method3"}) 
public void otherMethod() {
}
DmitriyH
  • 126
  • 7
  • Thanks for your response. dependsOnMethods = {"method1", "method3"} : by doing this, for execution of otherMethod() - method1 and method3, have to be passed. But In my case otherMethod is not logically depends on method3, i.e. even though method3 fails - otherMethod should execute. – omkar Mar 05 '20 at 12:17