I am trying to create a new test suite to test the old website I'm working on. The site uses a database on the back. I plan to use SpecFlow and Selenium, however I am a little puzzled that the best way to handle data cleaning is this.
I currently have a database backup with a set of sampled data that I restore before each run. This, however, is cumbersome, so I would like to do it only for critical tests before release and leave continuous integration runs working in the same database between them.
I currently have a large number of tests that go something like this:
Secenario: Test Item Creation Given I am logged in When I create an item with a unique name Then an item exists with the unique name
When a GUID is used in a step to guarantee the uniqueness of a name, then this step has access to it with a module variable to check if it exists.
As I said, I have many tests like this, and I run them several times in the same database, so the test system is filled with many objects that slow down the search, etc.
My question is the best way to handle this? Should I create another step in the test that will delete the element again as follows:
Secenario: Test Item Creation Given I am logged in When I create an item with a unique name Then an item exists with the unique name Then delete the item with the unique name
Or should my test framework somehow handle this? If so, what are people doing? Given the global nature of the SpecFlow step, I would suggest that getting the separation steps in the correct order if multiple elements with parent-child relationships can become problematic.
database specflow teardown scenarios
Martin brown
source share