我知道其中任何一个都可以,但我正在努力成为 ruby/cucumber 社区的更好成员。我有一个故事可以测试我网站的多个部分下是否没有任何链接,它不应该显示。那么这两种方式中哪一种是编写场景的最佳方式。再一次,我知道两者都可以,但我正在寻找最佳实践解决方案。我通常会使用选项 B,因为它们都在测试不同的“然后”步骤;但是我已经进行了一些研究,并且我在猜测自己,因为我可以使用相同的给定语句测试所有场景,并且我正在阅读您应该只在更改“给定”和“那么”步骤时才创建一个新场景.
一种。
Scenario: A user that cannot access A, B, C, or D
Given I am a, user without access to A, B, C, or D
When I navigate to reports
Then I see the A header
But I cannot click on A's header
And I see error message under A stating the user does not have access
And I do not see the B section
And I do not see the C section
And I do not see the D section
或者
B.
Scenario: A user that cannot access A
Given I am a, user without access to A
When I navigate to reports
Then I see the A header
And I see error message under A stating the user does not have access
But I cannot click on A's header
Scenario: A user that cannot access B
Given I am a, user without access to B
When I navigate to reports
Then I do not see the B section
Scenario: A user that cannot access C
Given I am a, user without access to C
When I navigate to reports
Then I do not see the C section
Scenario: A user that cannot access D
Given I am a, user without access to D
When I navigate to reports
Then I do not see the D section