我們開始使用C#內置單元測試功能。我爲VisualStudio 2008創建了單元測試代碼。我在生成的代碼上面有幾個問題。C#單元測試代碼問題
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
如果我需要的初始化和清除方法,做我需要刪除這些「我」,從法的名字時,我讓他們:以下是我的代碼從生成的文件複製?
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
我需要在運行第一個測試在什麼地方調用"MyClassInitialize"
方法或者它會被稱爲被稱爲其他方法之前自動。
其他三種方法的類似問題,他們是否在正確的時間框架自動調用?