I recently wrote some integration tests with ASP.Net MVC controller actions and was disappointed with the complexity of setting up test data that must be present to run the test.
For example, I want to test the actions of "add", "edit" and "delete" the controller. I can write an βaddβ test, but then find that to record the βeditβ test, I either had to call the βaddβ test code to create a record so that I could edit it, or make a lot of settings in the test class, none of which is not particularly attractive.
Ideally, I want to use or develop an integration test environment to make it easier to add seed to the reusable path for integration tests so that the arr / act / assert test organization aspect can focus on organizing what I especially need to organize my test, rather than touching yourself, with the placement of a load of reference data indirectly related to the code under the test.
I use NHibernate, but I believe that any functions for sowing data should not forget about it and be able to directly manipulate the database; ORM may change, but I will always use the SQL database.
I use NUnit, so I plan to connect to the installation / debugging of test / testfixture (but I think that a good solution could potentially be passed to other test environments).
I use FluentMigrator in my main project to control the scheme and sow the reference data, so it would be nice, but not important, to be able to use the FluentMigrator infrastructure for a consistent approach to the solution.
So my question is: "How do you use database data to test integration in C #?" Do you execute SQL directly? Do you use a framework?
source share