在Selenium关键字驱动的框架中执行并行测试

时间:2014-10-29 05:38:11

标签: selenium selenium-webdriver webdriver automated-tests selenium-grid

在数据驱动框架中,我们使用Selenium和TestNG并行运行多个测试。 如何在关键字驱动的框架中实施相同的工作?

在数据驱动方法中,我们可以将每个测试用例定义为一个单独的方法,因此我们可以通过注释命令TestNG运行哪些方法以及并行运行多少个。

在关键字驱动的方法中,每个测试用例都是一个单独的Excel工作表,同一工作簿中的多个Excel工作表构成了一个测试工具包。如何对这些Excel工作表/测试用例进行注释/引用,以便与数据驱动框架中的执行结构和流程并行运行?

我想到的一个蹩脚的解决方案是混合方法,其中创建可以调用excel表的方法。

例如:

@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);
}

我不确定他们上面的例子是否适合这样做。请求相同的建议。提前谢谢。

1 个答案:

答案 0 :(得分:1)

一种解决方案可以是:

  1. 有一张要执行的案例主表,作为你的套件。
  2. 让您的数据提供者读取此主表并使用单个@Test方法接收测试用例数据的参数。 这个测试用例基本上是读取步骤并执行 - 就像你的ReadAnExecureTestCase方法一样。
  3. 使用dataprovider线程计数使此数据提供程序并行并进行控制。