Global test initialize method for MSTest

后端 未结 3 1931
無奈伤痛
無奈伤痛 2020-12-24 00:45

Quick question, how do I create a method that is run only once before all tests in the solution are run.

3条回答
  •  温柔的废话
    2020-12-24 01:14

    Sorry for the crappy formatting...

            /// 
            /// Use TestInitialize to run code before running each test
            /// Runs before every test executes
            /// 
            [TestInitialize()]
            public void TestInitialize()
            {
               ...
               ...
            }
    
    
            /// 
            /// Use TestCleanup to run code after each test has run
            /// Runs after every test executes
            /// 
            [TestCleanup()]
            public void TestCleanup()
            {
               ...
               ...
            }
    

提交回复
热议问题