我正在使用Gherkin编写验收测试,其中我想根据初始操作测试Web应用程序的UI中的多个更改。以下是一个示例:
Scenario: Cancel editing a new text asset
Given the user "test_user@fakedomain.com" is logged in
When the user navigates to "/build/"
And the user clicks the "Sandbox" link
And the user inputs "Test story for canceling editing of a new text asset" for the "title" field
And the user inputs "Test User" for the "byline" field
And the user inputs "My summary, so exciting!" for the "summary" textarea
And the user clicks on "Untitled Section" in the section list
And the user clicks the "Text" icon in the "center" container
And the user inputs the following text in the rich text editor:
"""
Test text for asset. This is cool.
"""
And the user clicks the "cancel" button
Then the following text is not present:
"""
Test text for asset. This is cool.
"""
And the "Image" icon is present
And the "Text" icon is present
When the user refreshes the browser
And the user clicks on "Untitled Section" in the section list
Then the following text is not present:
"""
Test text for asset. This is cool.
"""
When the user opens the asset drawer
Then the following text is not present:
"""
Test text for asset. This is cool.
"""
请注意,存在多个When/Then步骤组,以测试初始操作的响应。虽然大多数步骤实现会忽略前缀关键字,而且我很确定我可以让这个测试运行,但是有没有更好的方法来测试不同的结果?编写具有相同设置但不同“Then”语句的多个场景是否更好的做法?