0

如果我有如下的类和 xml:

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>

注意:假设所有方法都会通过

执行顺序:

method1> method2> otherMethod> method3

因为method2otherMethod依赖于method1,所以它们先执行然后再method3执行,尽管method3之前otherMethod在 XML 中存在。

我们如何按照我们在 XML 中定义的顺序执行这些方法?

预期顺序:

method1> method2> method3>otherMethod

4

1 回答 1

0

似乎 otherMethod 取决于 method3 因为需要严格的顺序。在这种情况下,我建议将此依赖项添加到 otherMethod

@Test (dependsOnMethods  = {"method1", "method3"}) 
public void otherMethod() {
}
于 2020-03-04T11:22:32.290 回答