Preparing data for a SpecFlow scenario [closed]

2019-06-05 15:27发布

问题:

I'm going to test a complex scenario which expects several other steps to have performed prior to it.

For example , it can be equivalent to have proper data in a warehouse before goods are taken our from it. So in order for fetching to happen, it must first be made sure that there are products in the warehouse and there is a fetch-order. There may be seperate screens to insert products to the warehouse. So before I start testing the fetch scenarios i have to be ready with those.

What would be the best method to be ready with this data? I basically could think of two options.

  1. Go through the actual screens to prepare the data.

  2. Have a DB snapshot with prepared data to perform the wanted scenario.

I'm not sure which way I should move forward and would like to hear similar experiences from the people who have tried something like this.

回答1:

I would go with option 2 - you are testing some use case and you should not involve use cases tested by another tests. Test consists of some code driving the test and data used to perform the test. So if you need special data for the test you should have them prepared upfront instead of creating them by application logic.



回答2:

The other thing you could do is have a framework that inserts that data into the database. This way it can be reused in other scenarios and would be quicker than restoring a database every scenario