I have a lot of unit test that depend on a certain configuration of a database. I would like to execute a script every time I run the unit tests so the database is Ok and the tests do not fail due to wrong data at DB. I currently have a SQL script to put the right data at the DB.
Is there a way of doing that from Visual Studio (2008 would be great)?
Thanks in advance mates.
you could implement methods with atributes like [ClassInitialize]
and [AssemblyInitialize]
which are executed once before the first test in the class or assembly. In such a method you run the script.
You could also write a method which is called in every test ([TestInitialize]
) which knows if it had already been executed. This way you could run the script before every test that needs it, but not when you only run tests which do not need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With