Are there NUnit Test Case Attributes for specifying Configuration

后端 未结 2 1345
你的背包
你的背包 2020-12-21 10:01

I am writing an NUnit test that I want run only in the Release configuration. Is there an elegant way of doing this with a test case attribute? Right now, I am surrounding

相关标签:
2条回答
  • 2020-12-21 10:18

    You could use the [Category] attribute. If you mark release only tests with [Category("Release")] then exclude that category in your normal test run and include it in you release run.

    So now your test becomes

    [Test]
    [Category("Release")]
    public void MyReleaseOnlyTest()
    {
       // stuff
    }
    
    0 讨论(0)
  • 2020-12-21 10:25

    Add the Ignore attribute in #if preprocessor, rather than the entire test method.

    #if DEBUG
    [Ignore("Only to be run in release")] 
    #endif
    

    http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx

    You can also use the Conditional attribute

    [System.Diagnostics.Conditional("RELEASE")]
    
    0 讨论(0)
提交回复
热议问题