I want each of my testing (integration) methods to use a clean and consistent database and specific test data for each test.
Could you provide me some examples / code snippets and tell me which is best suited for the following questions for both scenarios, the EF 5 database and model first
- How to create a database for each test method?
- How to set up test data for each test method?
- How to delete a database for each test method?
- The SSDT project is used to process the database schema, how to use the existing SSDT schema for each test run? So that tests always run against the current version of the database.
Please consider the following assumptions for the following questions:
- Unit tests must be run locally on the dev machine and on the lines of the CI server.
- Each test may have different test data.
- Manually defined .mdf test files should be avoided manually, as some developers are working on the product, and there is a potential risk that one deleoper will overwrite changes to the .mdf file that another developer could check before โ the development process should be as simplex as possible.
- SSDT is used, so perhaps this is an option for creating a database (maybe not very good, because I want a database to be created for each test), and I do not have in-depth knowledge about the capabilities of SSDT.
- A good test runtime performance would be nice.
- Used by VS / TFS 2012.
- Used by SQL Server 2012.
- The application is a C # desktop application.
- Hide context EF, etc. not an option.
I hope you can direct me in the right direction, how to solve 4 questions from above. I donโt know if EF provides some functionality (I think, only for code) for its tasks, or if all this needs to be solved by executing SQL scripts or something like that.
Thanks!
source share