【发布时间】: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”没有被示例表中的字符串替换。也许我应该在给定的故事中声明我的论点?无论如何,我想知道如何将参数注入到我的故事中,并将尝试每种建议的方法。
谢谢。
【问题讨论】: