我为 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”没有被示例表中的字符串替换。也许我应该在给定的故事中声明我的论点?无论如何,我想知道如何将参数注入(inject)到我的故事中,并将尝试每一种建议的方法。
谢谢。
最佳答案
JBehave 的每一项功能在源代码中都有一个对应的示例。看看那些: GivenStoriesParametrisedByMeta GivenStoriesParametrisedByExamples GivenStoriesParametrisedByMeta
关于java - JBehave 故事参数示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18975105/