2011-09-29 21 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

相關問題