我有一个场景,我在调用一个方法(其中包含创建工作流的代码 - 在页面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失败,那么becoz @test方法将从头开始运行,而不是为'createWorkflow方法创建多个工作流。
您能告诉我如何实现这一目标或更好的解决方案。
答案 0 :(得分:0)
@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");
}