如果我有如下的类和 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
因为method2
和otherMethod
依赖于method1
,所以它们先执行然后再method3
执行,尽管method3
之前otherMethod
在 XML 中存在。
我们如何按照我们在 XML 中定义的顺序执行这些方法?
预期顺序:
method1
> method2
> method3
>otherMethod