我陷入了一个窘境,试图找出构建我的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堆栈压缩到一个场景中,这样我就不必担心执行顺序,还是有更好的方法来控制执行?