【问题标题】:jBehave Tabular ParameterjBehave 表格参数
【发布时间】:2019-01-10 15:31:19
【问题描述】:

所以我想使用 jBehave 的表格参数功能,但出于某种原因只考虑了第一列

故事

Given I login using the users $userTable
|url    |userRole   |
|http://localhost:3000  |Administrator  |
|http://localhost:3000  |User   |

步骤

@Given("I login using the users $userTable")
public void givenUrlIsAccessedUsingTable
      (@Named("userTable")ExamplesTable userTable) {
List<Map<String, String>> rows = userTable.getRows();
for (Map<String, String> row : rows) {
    setupPreconditions(row.get("url"), row.get("userRole"));
}

Actual result from report

用户列不存在。

我不明白我做错了什么?

【问题讨论】:

    标签: java bdd browser-automation jbehave


    【解决方案1】:

    请检查第一个':'是否缺少符号

     @Given("I login using the users: $userTable")
    

    第二个Given I login using the users:这里什么都没有,因为语句下的表格就是为了这个目的

    Given I login using the users:
    |url    |userRole       |
    |http://localhost:3000  |Administrator  |
    |http://localhost:3000  |User           |
    

    如果您使用的是 intellij idea,我建议使用 https://plugins.jetbrains.com/plugin/7268-jbehave-support

    格式化

    还有一件事:我建议为 tha 命名 鉴于用户进行日志记录:

    【讨论】:

    • 感谢您的建议,我已经有了 intellij 的插件。我也用你的方法得到了同样的结果。但是只要提一下,如果我从 Given 定义中省略了 userTable,那么 IDE 将不会喜欢它,因为无法识别该表。
    • 语法jbehave.org/reference/stable/tabular-parameters.html可以查看官方指南,希望对您也有帮助
    • 显然发生了一些奇怪的事情。我需要在故事中添加整个 Given 定义,然后从故事中手动删除 $userTable。谢谢。成功了
    • 顺便说一下,所有的描述都是空间敏感的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多