开发者

How to stage data using VS 2010 Unit Test Project

开发者 https://www.devze.com 2023-03-26 09:21 出处:网络
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'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 call开发者_如何学编程ed 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.

  • Method marked with[TestInitialize] runs before each test.
0

精彩评论

暂无评论...
验证码 换一张
取 消