c# - 如何在不同的前提条件下运行相同的 nunit 测试? (赛程)

标签 c# nunit

我有一组测试,必须在基类中使用两个不同的 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
      }
   }

关于c# - 如何在不同的前提条件下运行相同的 nunit 测试? (赛程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39529699/

相关文章:

nunit - AppDomain 中的冒号导致 log4net.Util.PatternString 出现问题

unit-testing - NUnit 与团队系统单元测试

c# - 如何在 C# 中进行非阻塞套接字调用以确定连接状态?

c# - 连续负数算法

c# - NUnit 'Assert' 不包含 'Multiple' 的定义

visual-studio - nUnit 测试适配器 10 秒限制 : long-running tests in nUnit

c# - 将 PDF 页面渲染到 CGBitmapContext 时如何减少内存使用?

c# - .NET OpenXML 性能问题

c# - 如何等待元素加载到 selenium webdriver 中?

c# - NUnit 3 CollectionConstraint 自定义 IComparer<T> 不工作