Question
Is there a way to have a method that will always run anytime that test assembly is run through MSTest?
Similar to how the [TestInitialize] and [ClassInitialize] attributes work, but for the entire assembly. I do not want to have to add code to every test class's [ClassInitialize] method.
Reasoning
Some of my tests interact with the database. They delete data and other things that would be very harmful to a production database. There is only a configuration file that tells my unit test project to run against the non-production database.
I would feel better if there was a method that would run on startup that would say "Okay Database name is not 'production'"
Ideas
Log4Net uses an assembly attribute to configure itself.
using log4net.Config;
[assembly: XmlConfigurator()]
Perhaps I can do something simliar?
[assembly: CheckDatabaseNameNot("production")]
Have you tried [AssemblyInitialize]?
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