Executing parallel tests in a Selenium keyword driven framework

感情迁移 提交于 2019-12-08 07:19:22

问题


In a data-driven framework, we use Selenium along with TestNG to run multiple tests in parallel. How can the same be implemented in a keyword-driven framework?

In data-driven approach we can define every test case as a separate method and therefore we are able to command TestNG via annotations which methods to run and how many to run in parallel.

In keyword-driven approach, every test case is a separate Excel Sheet and multiple excel sheets in the same workbook make a test suite. How can these excel sheets/test cases be annotated/referred so as to run in parallel similar to the execution structure and process in data-driven framework?

One lame solution I thought of was a hybrid approach wherein creating methods which would call the excel sheet.

For eg.:

@Test
public void TestCase_001() {
       // Read the keyword driven test case
       // XLS_WorkbookName - The Excel Workbook or Test Suite containing multiple Test Cases
       // XLS_SheetName - The Excel Sheet containing set of rows each of which contains ID of element, Operation to be performed and data to be used
       ReadAndExecuteTestCase(XLS_WorkbookName_XYZ, XLS_SheetName_ABC);
}

@Test
public void TestCase_002() {
       // Read the keyword driven test case
       // XLS_WorkbookName - The Excel Workbook or Test Suite containing multiple Test Cases
       // XLS_SheetName - The Excel Sheet containing set of rows each of which contains ID of element, Operation to be performed and data to be used
       ReadAndExecuteTestCase(XLS_WorkbookName_ABC, XLS_SheetName_XYZ);
}

I'm not sure if they above example is the appropriate way to go about it. Requesting suggestions to the same. Thanks in advance.


回答1:


One solution can be :

  1. Have a master sheet of cases to execute, which acts as your suite.
  2. Have your dataprovider read this master sheet and have a single @Test method which takes in the arguments of the testcase data. This testcase basically reads the steps and executes - something like your ReadAnExecureTestCase method.
  3. Make this dataprovider parallel and control using dataprovider thread count.


来源:https://stackoverflow.com/questions/26623425/executing-parallel-tests-in-a-selenium-keyword-driven-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!