是否可以在 Cucumber/Cuke4Duke 中使用 2 个不同的示例表

发布于 2024-12-07 19:27:17 字数 264 浏览 0 评论 0原文

是否可以以某种方式构建一个在不同步骤中使用两个不同示例表的场景?像这样的事情:

Given I log in
When I view a page
Then I should see <goodText>
Examples:
|goodText|
|abc|
And I should not see <badText>
Examples:
|badText|
|xyz|

上面的场景不起作用,而且实际上每个表会有更多行。

Is it possible to somehow construct a Scenario which uses two different Example tables in different steps? Something like this:

Given I log in
When I view a page
Then I should see <goodText>
Examples:
|goodText|
|abc|
And I should not see <badText>
Examples:
|badText|
|xyz|

The scenario above doesn't work, also in reality there would be more rows to each table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纸伞微斜 2024-12-14 19:27:17

看起来您将表格与场景示例混淆了。您可以混合它们,但从您的示例来看,我不确定您想要实现什么目标。为什么不直接写:

Given I log in
When I view a page
Then I should see "abc"
But I should not see "xyz"

或者如果你想检查多个字符串:

Given I log in
When I view a page
Then I should see the following text:
  | abc |
  | def |
But I should not see the following text:
  | xyz |
  | uvw |

It looks like you're confusing tables with scenario examples. You can mix them, but from your example I'm not sure what you're trying to achieve. Why not just write:

Given I log in
When I view a page
Then I should see "abc"
But I should not see "xyz"

or if you wanted to check for multiple strings:

Given I log in
When I view a page
Then I should see the following text:
  | abc |
  | def |
But I should not see the following text:
  | xyz |
  | uvw |
把梦留给海 2024-12-14 19:27:17

您说实际上表中会有更多行;当然,一个表也可以有很多列。

这对你不起作用吗?

Given I log in
When I view a page
Then I should see <goodText>
But I should not see <badText>
Examples:
|goodText| badText |
|abc     | xyz     |

You say that in reality there would be many more rows to the table; but of course a table can also have many columns.

Would this not work for you?

Given I log in
When I view a page
Then I should see <goodText>
But I should not see <badText>
Examples:
|goodText| badText |
|abc     | xyz     |
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文