EF - integration tests on the existing database schema with source data

Our team is developing a web service (C #, EF 6, Code first with an existing database). The database is being developed and maintained by another team. We cannot make any changes to the database.

I would like to test our application against a real database schema to make sure that our code is compatible with the changes made by the database team. I want to achieve this, I would like to avoid making changes (for example, automatic schema changes made by Migrations) to the test database schema.

I would like to remove the real data and insert the test data to make the tests more reliable.

How to do it? I am using EF 6.0.

Do you recommend doing this as follows?

  • Once the automatic task restores a copy of the real database on the test server and runs an SQL script to delete all the data ( https://stackoverflow.com/a/2127161 )

  • When a user runs integration tests, the test initializer deletes data from the test database and inserts the original data. Then integration tests are performed.

+4
source share

Source: https://habr.com/ru/post/1543185/


All Articles