Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaning up data after a selenium test

I'm setting up some Selenium tests for an internal web app and looking for advice on a testing 'best practice'. One of the tests is going to add some data via the UI that cannot be removed via the UI (e.g., you can add a record via the web app, but removing requires contacting someone internally to remove it at the database level). How do you typically account for cleaning up data after the Selenium test is run?

The app in question is written in PHP and I'm using PHP for testing (with Selenium RC and SimpleTest), but I'm open to other tools, etc. as this is just a broad best practice question. The app being tested is in our development environment, so I'm not particularly worried about data carrying over from tests.

Some ideas:

  1. Manually connect to the database in the Selenium test to clean up the data
  2. Use something like DBUnit to manage this?
  3. Just add data and don't worry about cleaning it up (aka, the lazy approach)

Thanks!

Edit: Seems most of the ideas centered around the same conclusion: work off a known set of data and restore when the tests are finished. The mechanism for this probably will vary depending on language, an amount of data, etc. but this looks like it should work for my needs.

like image 474
Rob Avatar asked Mar 19 '09 16:03

Rob


People also ask

Where do you keep the test data in Selenium?

Currently we have test data stored in variables in our tests. We use variables e.g. private final static String SOME_DATA ="value"; which we can reuse across tests from given TestClass but if we need it in another Test Class we have to repeat it there.

What are the important phases of the Selenium test process?

Test plan: Get the application environment specifications from the development team. Then, identify the objects in the Application which is under test. Further, create the test cases and select the appropriate framework based on the requirements.


1 Answers

I use Selenium with a Rails application, and I use the fixture mechanism to load and unload data from the test database. It's similar to the DbUnit approach, though I don't unload and reload between tests due to the volume of data. (This is something I'm working on, though.)

like image 175
Sarah Mei Avatar answered Sep 20 '22 16:09

Sarah Mei