【问题标题】:JBehave story parameters sampleJBehave 故事参数示例
【发布时间】:2023-03-17 07:20:01
【问题描述】:

我为 JBehave 自动测试编写故事场景。这里需要写几个类似的场景,不同的是常量参数。

为了不复制大量脚本,我希望在我的故事中添加参数并使用不同的参数多次调用它。

如何使用“GivenStories”来做到这一点?

在这里我找到了关于如何做到这一点的教程http://jbehave.org/reference/preview/given-stories.html,但缺乏关于它如何工作的示例。 我试图这样做:

Scenario:  A scenario in which the user can run other stories as pre-requisites
           parametrized using the rows of the Examples table

GivenStories: path/to/precondition.story#{0},
              path/to/precondition.story#{1}

Given ... // normal scenario steps

Examples:
|One|Two|
|uno|due|
|un|deux|

但是字符串“One”和“Two”没有被示例表中的字符串替换。也许我应该在给定的故事中声明我的论点?无论如何,我想知道如何将参数注入到我的故事中,并将尝试每种建议的方法。

谢谢。

【问题讨论】:

    标签: java jbehave


    【解决方案1】:

    JBehave 的每个功能在源代码中都有一个对应的示例。看看那些: GivenStoriesParametrisedByMeta GivenStoriesParametrisedByExamples GivenStoriesParametrisedByMeta

    【讨论】:

      【解决方案2】:

      我发现了我的错误。我试图将变量名放在带括号的表格中

      【讨论】:

        猜你喜欢
        • 2011-05-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-07
        • 1970-01-01
        • 1970-01-01
        • 2019-12-31
        相关资源
        最近更新 更多