如何使用黄瓜标签实现黄瓜并行执行?

时间:2020-08-07 18:49:53

标签: parallel-processing cucumber cucumber-java cucumber-serenity

我正在尝试使用Cucumber标签实现并行执行。我在下面附加了功能文件,而不是使用多个功能文件,而是尝试使用黄瓜标签@au,@nl, @nz

来实现我的方案的并行执行

我知道我们可以使用功能文件来实现并行执行,但是我想使用黄瓜标签根据区域设置并行执行我的标签。每个标签都与现有客户进行相关测试。

注意:我正在使用宁静BDD

 1. browser 1: au (first execute new user, second execution for existing user )
 2. browser 2: nl (first execute new user, second execution for existing user )
 3. browser 3: nz (first execute new user, second execution for existing user )

sample.feature

 @au  @smoke
  Scenario: A new user can place a order
    Given the user is on homepage
    When the user perform checkout
    Then order confirmation page is display
    
  @au  @smoke
  Scenario: A new user can place a order
    Given the existing user is on homepage
    When the existing user perform checkout
    Then order confirmation page is display
    
  @nl  @smoke
  Scenario: A new user can place a order
    Given the user is on homepage
    When the user perform checkout
    Then order confirmation page is display
    
  @nl  @smoke
  Scenario: A new user can place a order
    Given the existing user is on homepage
    When the existing user perform checkout
    Then order confirmation page is display
    
    
  @nz  @smoke
  Scenario: A new user can place a order
    Given the user is on homepage
    When the user perform checkout
    Then order confirmation page is display
    
  @nz  @smoke
  Scenario: A new user can place a order
    Given the existing user is on homepage
    When the existing user perform checkout
    Then order confirmation page is display

1 个答案:

答案 0 :(得分:0)

如果您使用的是黄瓜4及更高版本,可以这样做

import io.cucumber.core.cli.main

public class MyRunner {

  public static void main(String[] args) {
    Main.run(new String[]{
        "--threads", "3",
        "-t", "@au and @nz",
        "-g", "com.your.glue",
        "src/test/resources/features/",
      }, Thread.currentThread().getContextClassLoader());
  }
}

注意:

  1. 这对我适用于黄瓜6.1.0。
  2. 您甚至可以使用testNG代替main方法。
  3. 您需要注意webdriver线程安全性