簡體   English   中英

如何在不同的前提條件下運行相同的nunit測試? (固定裝置)

[英]How to run the same nunit tests with different preconditions? (fixtures)

我有一組測試,並且必須在基類中使用兩個不同的SetUp運行它。

這是截圖 http://screencast.com/t/G150W2P4o

我該如何改善?

創建一個參數化的測試夾具。 將有關應使用哪種設置(可能是OneTimeSetUp)的信息傳遞給燈具的每個實例。 信息必須是常量值(例如字符串),以便可以用作屬性的參數。

例如...

   [TestFixture("setup1", 5)]
   [TestFixture("setup2", 9)]
   public class MyTestFixture
   {
      public MyTestFixture(string setup, int counter)
      {
         // You can save the arguments, or do something 
         // with them and save the result in instance members
      }

      [Test]
      public void SomeTest()
      {
         // Do what you need to do, using the arguments
      }
   }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM