1

I am at the point of creating data for integration test of my app, which contains from the web-services layer till the persistence. I have 2 main alternatives for achieving this, but I'm worried about the maintenance of the data generated for the tests. I mean, if I generate the data programatically, I think that updating this code to the newest version will be easier than updating an script which generates the data.

What is the most common way of generating data for testing?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

1

If you are just unit testing, its good to mock up database connection and data.

If you are doing end to end testing, you need to design your test in such a way that it will create data, perform tests and then finally remove data.

Most of the time you have services for CURD operation. You need to use existing services intelligently. Following approach worked for me. - check if data exists. (using id reserve for test). Remove data if its already there. - create data using service. (e.g. have some unique id). - perform update and fetching operation. - finally delete test data.

This would be clean approach and you might want to use your DEV database for this.

There might be better approach than this but above worked for me.

neo
  • 1,054
  • 1
  • 10
  • 19