在Selenium关键字驱动的框架中执行并行测试 [英] Executing parallel tests in a Selenium keyword driven framework
问题描述
在数据驱动的框架中,我们将Selenium与TestNG一起使用以并行运行多个测试. 如何在关键字驱动的框架中实现相同的功能?
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?
在数据驱动的方法中,我们可以将每个测试用例定义为单独的方法,因此我们可以通过注释命令TestNG哪些方法可以运行,哪些可以并行运行.
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.
在关键字驱动的方法中,每个测试用例都是一个单独的Excel工作表,并且同一工作簿中的多个excel工作表构成一个测试套件.如何对这些excel表格/测试用例进行注释/引用,以使其与数据驱动框架中的执行结构和过程类似地并行运行?
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?
我想到的一个la脚的解决方案是一种混合方法,其中创建了称为excel工作表的方法.
One lame solution I thought of was a hybrid approach wherein creating methods which would call the excel sheet.
例如:
@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.
推荐答案
一种解决方案可以是:
- 具有要执行的案例的主表,可以作为您的套件.
- 让您的数据提供者阅读此主表,并使用单个@Test方法接收测试用例数据的参数. 该测试用例基本上可以读取步骤并执行-类似于您的ReadAnExecureTestCase方法.
- 使此数据提供程序并行并使用dataprovider线程数进行控制.
- Have a master sheet of cases to execute, which acts as your suite.
- 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.
- Make this dataprovider parallel and control using dataprovider thread count.
这篇关于在Selenium关键字驱动的框架中执行并行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!