我陷入了一個窘境,試圖找出構建我的CRUD測試的方式最佳。在我的應用程序中,用戶可以創建多種類型的「任務」。我目前實現看起來像下面這樣:如何使用BDD構建CRUD測試
Scenario: Create Task-Type A
Given I am on a user's profile page
And Have access to create tasks
When I create a new task with a unique title and description
Then The confirmation prompt should display
Scenario: Read the Task-Type A
Given A new task was created
When I search the text on the page for the unique title
Then I should find the task
And All the details of the task should match what was created
Scenario: Update the Task-Type A
Given A task exists
And I have opened the edit dialog
When I make the following changes:
| title | description | date | save |
| "" | "" | "" | yes |
Then all the saved changes should match the task details
Scenario: Delete the Take-Type A
Given A task exist
When I select the option to delete
And I confirm deletion process
Then The Task should no longer exist in the list
我尋求幫助,在這裏是因爲我無法控制的CRUD步驟執行順序的原因。我使用的是Specflow和NUnit,它按字母順序執行場景,而不是它們在特性文件中出現的順序。這導致這個順序C> D> R> U,這在運行時當然會崩潰和燃燒。
我試圖在場景名稱的開頭添加字符,導致類似於「場景:階段1創建...」,「場景:階段2讀取...」等內容。但是,當我做出這個改變時,我忍不住想到它的感覺如何「黑暗」。我已經做了一些研究,但大部分都是用空白來更好地控制執行順序。
我確實有多個這些CRUD測試要寫入;每種類型的「任務」都有一個,我想知道是否最好將整個CRUD堆棧壓縮到一個場景中,這樣我就不必擔心執行順序,還是有更好的方法來控制執行?