Integration Testing automation - checking DB value

2019-08-18 20:11发布

问题:

I'm dealing now with a problem during creating automation of integration test.

I would like to:

  1. input data via selenium RC
  2. check if values are correct in DB after import.

I've got problem with logic of those tests. Now I do it as it follows: in one test I generate random data (first name, last name, etc of the person). Then, by simple select from DB I obtain unique person_id key (I assumed that if first and last name are both 8 characters long, random generated strings I can treat them as unique) and then use this id in next queries.

Is this method correct? If not, how can I deal with it?

回答1:

What exactly is the purpose of this integration test?

If you're testing your DB adaptor layer, then is there any need to use the Web UI? You can exercise the adaptor directly.

If you're testing the Web UI is there any need to actually store data in a database? You can check the values using a mock (or some other sort of test double).

If you're doing an end-2-end skim test, is it necessary to check the actual data values (over and above the success of the actual interaction)? And if the answer is yes, maybe the test should be along the lines of:

Given I have registered as "Random Person"
When I retrieve my details
Then my name is displayed correctly.