忽略文件中的所有 NUnit 测试
我可以在测试上添加一个属性来忽略它:
[Test]
[Ignore("Foo Bar")]
Is有一种方法可以忽略文件中的所有测试(在 TestFixture 级别)?
I can add an attribute on a test to ignore it:
[Test]
[Ignore("Foo Bar")]
Is there a way to ignore all tests in a file (at the TestFixture level)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
或者,如果您希望将属性分解为每行一个:
Or if you prefer to break your attributes out to one per line:
正如所建议的,
[Explicit]
属性效果很好。 将[Ignore()]
属性放置在[TestFixture]
属性下,如文档中所示:您还可以简单地 nunit.org/index.php?p=ignore&r=2.5" rel="noreferrer">http://www.nunit.org/index.php?p=ignore&r=2.5
使用
[Ignore()]
如果您希望测试被标记为忽略(因此,如果所有其他测试都通过,您会看到黄色条)。 如果您希望测试完全折扣(因此,如果所有其他测试都通过,您会得到绿色条),请使用[Explicit]
。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).您可以使用
[Explicit]
属性使整个TestFixture
成为“按需”。 然后,当您需要它时,它就在那里,但只有当您明确单击它时。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.在 NUnit 2.5 之前,从类中删除
[TestFixture]
属性似乎可行。NUnit 2.5 及更高版本的情况并非如此,其中
[TestFixture]
属性对于非参数化非通用夹具是可选的。 请参阅此处了解更多信息。Before NUnit 2.5, removing the
[TestFixture]
attribute from the class seems like it would work.This is not the case for NUnit 2.5 and later in which the
[TestFixture]
attribute is optional for non-parameterized non-generic fixtures. See here for more.只是不要在类上应用 TextFixture 属性。
Simply don't apply the TextFixture attribute on the class.