根据TestNG官方documentation: DependsOnGroups和dependsOnMethods都接受正则表达式作为参数。
但是当我尝试它时,得到了循环依赖测试异常。
代码:
onDataChange()
导入org.testng.annotations.Test;
公共类RegularExpressionsInDependsOnMethod2 {
package Dependecy;
}
控制台错误: [RemoteTestNG]检测到TestNG版本6.14.2 org.testng.TestNGException: 以下方法具有循环依赖性: RegularExpressionsInDependsOnMethod2.Module2_purchaseSomething()[pri:0,实例:Dependecy.RegularExpressionsInDependsOnMethod2@215be6bb]
// Tests belong to Module 1
@Test()
public void Module1_signUp()
{
System.out.println("Signed Up");
}
// Tests belong to Module 1
@Test()
public void Module1_logIn()
{
System.out.println("Logged In");
}
// Tests belong to Module 2 and depends on Module 1 methods named signUp and logIn.
@Test (dependsOnMethods= "Module1.*")
public void Module2_purchaseSomething()
{
System.out.println("purchased Something");
}