2011-09-29 33 views
1

是否可以以某种方式构建一个在不同步骤中使用两个不同示例表格的方案?这样的事情:是否可以在Cucumber/Cuke4Duke中使用2个不同的示例表格

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| 

上面的情况不起作用,实际上也会有更多的行到每个表。

回答

1

它看起来像你与表情场景示例混淆表。你可以混合它们,但从你的例子我不知道你想要达到什么。为什么不只是写:

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 | 
+0

如上所述,表中会有更多的行,而不仅仅是我写的简单示例。 – C0deAttack

+0

我编辑了我的帖子,以说明如何做到这一点。不需要场景大纲。 –

+0

嗯,那么如果我没有占位符,我如何在我的步骤中访问'abc','def'等? – C0deAttack

0

你说,在现实中会有更多的行表;但当然一张桌子也可以有很多列。

这不适合你吗?

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  | 
+0

不,因为并不总是有相同数量的goodText和badText。尽管在上面的答案中看到了评论,但我已经完成了。 – C0deAttack

相关问题