I’m setting up some unit tests in VS 2010 using .Net 4.0 using the test project and the [TestMethod] decorations. Some of my tests require some data to be staged in the database prior running.
I created a method called StageUserStoreData() which does this. How can I make the method run prior to running any of the tests? Ideally, I would only like this method called once, that is once the data is staged, I do not need to call it again.
There are three kinds of initialization methods, and they run in the following order:
Method marked with
[AssemblyInitialize]runs before any tests in the assembly.(Note that it still has to be inside a
[TestClass])Method marked with
[ClassInitialize]runs before any tests in the class.[TestInitialize]runs before each test.