2018-03-19

1 背景

当case之间有依赖关系,有依赖关系的case,它们的执行顺序是有限制的。TestNG提供了依赖管理功能

2 基础理论

这个执行顺序可以用拓扑排序算法实现。

只要是有向无环图就能被拓扑排序,拓扑排序维基典型实现算法:

L ← Empty list that will contain the sorted elements
S ← Set of all nodes with no incoming edges
while S is non-empty do
    remove a node n from S
    insert n into L
    foreach node m with an edge e from n to m do
        remove edge e from thegraph
        if m has no other incoming edges then
            insert m into S
if graph has edges then
    return error (graph has at least one cycle)
else 
    return L (a topologically sorted order)

TestNG依赖管理功能

  • dependsOnMethods
@Test  
public void serverStartedOk(){}  
@Test(dependsOnMethods={ "serverStartedOk" })  
public void method1() {}  
View Code

相关文章:

  • 2021-07-11
  • 2021-11-16
  • 2022-03-05
  • 2022-01-17
  • 2022-12-23
  • 2021-09-11
猜你喜欢
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案