我有一个场景,在我调用一个方法(其中包含创建工作流的代码 - 在页面 POM 框架中定义)时,我编写了一个通用方法来使用 testNG 中的 dataProvider 从 excel 文件中获取数据
现在我有一个 @Test 方法,它执行创建工作流的操作,如下所示
@DataProvider(name="wf")
public static String[][] getExcelData() throws Exception{
ExcelReader read = new ExcelReader();
String filePath = "path of excelfile";
return read.getCellData(filePath, "Sheet1");
}
@Test(dataProviderClass = ExcelReader.class, dataProvider="wf")
public void testing(String workflow, String type, String unit){
System.out.println("-------------Test case started -------------");
System.out.println("Call to login to the application");
System.out.println("Navigating to Some Page");
System.out.println("Navigating to WorkflowPage");
SampleClass s = new SampleClass();
s.createWorkflow(workflow,type,unit);
System.out.println("-----'--------Test case Ended ----------------");
System.out.println();
}
public void createWorkflow(String wf, String wf, String unit){
System.out.println("Creating WF");
System.out.println(wf);
System.out.println(type);
System.out.println(unit);
System.out.println("CREATED wf");
}
现在,如果我在创建第一个工作流后运行 @Test 失败,那么 @test 方法会从头开始再次运行,而不是为“createWorkflow 方法”创建多个工作流。
你能让我知道我怎样才能实现这个或更好的解决方案。
@BeforeMethod
public void beforeMethod(){
System.out.println("Call to login to the application");
System.out.println("Navigating to Some Page");
System.out.println("Navigating to WorkflowPage");
}
@Test(dataProviderClass = ExcelReader.class, dataProvider="wf")
public void testing(String workflow, String type, String unit){
System.out.println("-------------Test case started -------------");
SampleClass s = new SampleClass();
s.createWorkflow(workflow,type,unit);
System.out.println("-----'--------Test case Ended ----------------");
System.out.println();
}
public void createWorkflow(String wf, String wf, String unit){
System.out.println("Creating WF");
System.out.println(wf);
System.out.println(type);
System.out.println(unit);
System.out.println("CREATED wf");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句