您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > Nunit
在.NET環(huán)境中使用單元測試工具Nunit
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/4/8 15:59:45 ] 推薦標(biāo)簽:

  底下這段程序代碼示范了如何使用TestFixtureSetUp/TestFixtureTearDown

  namespace UnitTestingExamples
  {

  using System;

  using NUnit.Framework;

  [TestFixture]
  public class SomeTests
  {

  [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” );

  }

  }

  }

  程序的輸出將是下面的結(jié)果::

  TestFixtureSetUp

  SetUp

  Test1

  TearDown

  SetUp

  Test2

  TearDown

  TestFixtureTearDown

  如果Test2單獨(dú)執(zhí)行輸出的結(jié)果將是:

  TestFixtureSetUp

  SetUp

  Test2

  TearDown

  TestFixtureTearDown

上一頁1234下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd