我正在編寫一個驗證測試,在希望測試基於初始操作的Web應用的UI中的多個更改的小黃瓜中。下面是一個示例:可以在單個小黃瓜場景中有多組Given/When/Then
Scenario: Cancel editing a new text asset
Given the user "[email protected]" 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」語句編寫多個場景是否更好?
嗯。不回答是否可能的問題。現在到更多谷歌搜索... – djangofan
可能的重複[是否可以寫一個「給予當然後當然後」測試在小黃瓜?](https://stackoverflow.com/questions/12060011/is-it-acceptable-當我在小黃瓜上試驗的時候寫下一個給定的答案) –
我不同意接受的答案;我添加了[我的回答](https://stackoverflow.com/a/45245799/634576)這是一個重複的問題。 –