TestFixTureTep and TestFixTureTeardown properties in NUnit

zhaozj2021-02-16  49

a) TestFixTureTUP and TestFixTureTeardown run once before all tests (TestFixTureTeartown) before all tests (TestFixTureteTeadown). Remember that he only runs once, regardless of how many TEST functions. So a TestFixTure can only have a TestFixTureTUP or TestFixTureTeadown. Example: test [TestFixture] public class TestFixtureSetUpAndTearDownTest {[TestFixtureSetUp] public void RunBeforeAllTests () {Console.WriteLine ( "TestFixtureSetUp");} [TestFixtureTearDown] public void RunAfterAllTests () {Console.WriteLine ( "TestFixtureTearDown");} [ SetUp] public void RunBeforeEachTest () {Console.WriteLine ( "SetUp");} [TearDown] public void RunAfterEachTest () {Console.WriteLine ( "TearDown");} [Test] public void Test1 () {Console.WriteLine ( "TEST1");

Test class [TEST] public void test2 () {console.writeline ("test2");}} Run Results: TestFixTureetupsetupTest2TeardownTestFixTureTeartown

转载请注明原文地址:https://www.9cbs.com/read-20574.html

New Post(0)