简体   繁体   中英

NUnit ignore all tests

I can add an attribute on a test to ignore it

[Test]
[Ignore("Foo Bar")]

Is there any way to ignore all tests in a file (at the TestFixture level) ?

[TestFixture, Ignore("reason")]
public class YourTestFixture { }

Or if you prefer to break your attributes out to one per line:

[TestFixture]
[Ignore("reason")]
public class YourTestFixture { }

As suggested, the [Explicit] attribute works well. You can also simply place the [Ignore()] attribute under the [TestFixture] attribute, as shown in the documentation:

http://www.nunit.org/index.php?p=ignore&r=2.5

Use [Ignore()] if you want the test to be flagged as ignored (and therefore you get the yellow bar if all other tests pass). Use [Explicit] if you want the test to be completely discounted (and therefore you get the green bar if all other tests pass).

Removing the [TestFixture] attribute from the class seems like it would work.

Edit: This answer became wrong starting with NUnit 2.5 when the [TestFixture] attribute became optional for non-parameterized non-generic fixtures. See here for more.

You can make the whole TestFixture "on-demand" by using the [Explicit] attribute. Then it's there when you want it, but only when you explicitly click on it.

只是不要在类上应用TextFixture属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM