Programmatically skip an nunit test

前端 未结 2 1237
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 00:38

Is there a way for an nunit test to end and tell the test runner that it should be considered skipped/ignored, rather than succeeded or failed?

My motivation for thi

相关标签:
2条回答
  • 2020-12-10 01:18
    Assert.Ignore();
    

    is specifically what you're asking for, though there is also:

    Assert.Inconclusive();
    
    0 讨论(0)
  • 2020-12-10 01:23

    I am having a TestInit(), TestInitialize method where there is a condition like:

        //This flag is the most important.False means we want to just ignore that tests
        if (!RunFullTests)
            Assert.Inconclusive();
    

    RunFullTests is a global Boolean variable located in a constant class. If we set this to false the whole test class will be ignored and all the tests under this class will be ignored.

    I use this when there are integration tests.

    0 讨论(0)
提交回复
热议问题