在 TestNG 的 PageObjectModel 中使用 dataprovider 传递数据

Passing data using dataprovider in PageObjectModel in TestNG

我有一个场景,在我调用一个方法(它有创建工作流的代码 - 在页面 POM 框架中定义)时,我编写了一个通用方法来使用 dataProvider 从 excel 文件中获取数据测试NG

现在我有一个 @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");
}