I am writing integration tests for an application and have not been able to find any best practices on how to set up a test database for my integration suite. I am working o
If you are using NUnit, you could use Setup/Teardown
attribute with TransactionScope
to not commit your changest to the database:
[SetUp]
public void SetUp()
{
transaction = new TransactionScope();
}
[TearDown]
public void TearDown()
{
if(transaction != null)
transaction.Dispose();
}
If you are using some other unit test framework it should have simmilar attributes. I would recomend creating a base class DbItegrationTest
for all your integration test fixtures so if you derive from this class all test methods won't do commits to database.
To configure Entity Framework for other database please override db connection string in your test assembly.