如何只执行场景大纲的几个随机示例?

How to execute only few random Examples for Scenario Outline?

场景大纲:登录 FaceBook

Given Enter "<emailId>"

And Enter the "<password>"

When Click on Login button

Then Navigated to HomePage

示例:

|电子邮件 ID |密码 |

|abc@***.com| abcd |

|123@***.com|第1234章|

|@#$@***.com| !@#$ |

-> 我只想用“123@***.com”执行测试用例。我们怎样才能做到这一点?

当我放置 2 个示例时,我在第二个示例中遇到编译错误 "missing EOF at 'Examples:'"。

提前致谢。

您可以使用标志控制后续步骤的执行。场景大纲:创建

Given Enter "<emailId>"
And Enter Password "<password>"
And Check "<runFlag>"
When Click on Login button
Then Navigated to HomePage

Examples: 
  | emailId         | password | runFlag  |
  | abc@***.com     |     abcd | N        |
  | 123@***.com     |     1234 | Y        |
  | @#$@***.com     |     !@#$ | N        |

然后使用标志变量创建您自己的逻辑来控制后续步骤的执行流程和断言

private static String flag;

    @Given("^Enter \"([^\"]*)\"$")
    public void enter(String username) throws Throwable {
        System.out.println("=============================================================");
        System.out.println("Username: " + username);
    }

    @Given("^Enter Password \"([^\"]*)\"$")
    public void enter_p(String password) throws Throwable {
        System.out.println("Password: " + password);
    }

    @Given("^Check \"([^\"]*)\"$")
    public void check(String runFlag) throws Throwable {
        System.out.println("Run Flag: " + runFlag);
        flag = runFlag;
    }

    @When("^Click on Login button$")
    public void click_on_Login_button() throws Throwable {
        if("Y".equalsIgnoreCase(flag)){
            System.out.println("Clicked Login");
        }else{
            System.out.println("Skipped: RunFlag=" + flag);
        }
    }

    @Then("^Navigated to HomePage$")
    public void navigated_to_HomePage() throws Throwable {
        if("Y".equalsIgnoreCase(flag)){
            System.out.println("Navigated to homepage");
        }else{
            System.out.println("Skipped: RunFlag=" + flag);
        }
    }