将值列表传递到黄瓜方案大纲

问题描述 投票:2回答:2

我有一个验证100个员工姓名的方案,QueryString将以xml格式返回它们。我要做的就是在一个Assertion语句中验证所有员工姓名,如下所示。是否可以发送100个员工姓名的列表作为输入,而不是在“方案大纲示例”中添加每个姓名,以便我可以在Java中对其进行迭代并可以轻松地在“断言”条件下进行验证。请指教。

Scenario Outline: When the User queries for employee information, the correct records are returned
    Given the webservice is running
    When the User queries for employee information "<QueryString>"
    Then the User receives correct data "<Name>"

Examples:
|QueryString|Name|
|Some localhost url|Peter|
|Some localhost url|Sam|
.
.

@Then("^the User receives correct data\"([^\"]*)\"$")
    public void the_user_receives_correct_data(String arg1) throws Throwable {
        queryResultPage = selenium.getPageSource();
        assertTrue(queryResultPage.contains(arg1));
    }
cucumber cucumber-jvm
2个回答
0
投票

所以我将在这里回答LINGS评论您可以做的是在步骤定义中使用这些文件名将文件加载到代码中。据我所知,黄瓜不支持直接文件加载。我用这样的东西来为我的相对路径文件名找到完整的资源路径:

public static String getAbsoluteResourcePath(String resourcePath) {

    if (SystemUtils.IS_OS_WINDOWS) {
      return Utils.class.getResource(resourcePath).getPath().substring(1).replace("/", File.separator);
    } else {
      return Utils.class.getResource(resourcePath).getPath().replace("/", File.separator);
    }
}

然后,resourcePath应该是您的相对文件路径


0
投票

您正在寻找的是QAF支持的外部测试数据支持。您可以将inbuilt data providerinterceptor一起使用,以修改数据集或custom data provider

[如果您使用的是5+以上版本的黄瓜,则可以使用qaf-cucumber,它将为您提供黄瓜的所有qaf功能。对于lower version,您可以使用QAF运行程序运行现有功能文件。

© www.soinside.com 2019 - 2024. All rights reserved.