pre-conditions and database interaction
let me ask you something, if a have scenario like this:
Scenario: Listing the questions for a user that has answered questions
Given I am a logged user called "vintem"
And I have the following projects
| Project |
| Project 1 |
| Project 2 |
When I visit the projects page
开发者_运维知识库 Then I should see
| Project |
| Project 1 |
| Project 2 |
What would you generally do in this case to create the projects the must be seen in the projects page? Suppose I am using a Repository pattern would call the repository itself to create the projects? Or simulate the creation of the projects using Watin? In the case of calling the repository directly, my connection to database would have to be same as the one in the web project right? I can't have a test db and a dev db in that case. Thanks
Your Given is there to set the context. It does not have to use the same constructs as the When or the then. You could if you wished just insert the projects in to the DB with straight SQL, It doesn't matter. What I wouldn't do is user Watin to set up the projects. This will make your tests more brittle as changes to the UI will effect your test. They will also run slower
You say you are using the repository pattern. As indicated I'd use that along with sqllite for the back-end.
精彩评论