是否有NUnit的测试用例属性用于指定配置 [英] Are there NUnit Test Case Attributes for specifying Configuration
本文介绍了是否有NUnit的测试用例属性用于指定配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写,我想只有在发布配置运行NUnit测试。是否有与一个测试用例属性,这样做的一个优雅的方式?现在,我周围的整个功能块与编译器指令:
我使用NUnit 2.5.6.10205
#如果!DEBUG
[测试]
公共无效MyReleaseOnlyTest()
{
//东西
}
#ENDIF
解决方案
您可以使用 [类别]
属性。如果标记仅释放测试, [类别(发行)]
然后排除类别中的正常试运行,并将其包含在你松开运行。
所以,现在你的测试变得
[测试]
[类别(发行)]
公共无效MyReleaseOnlyTest()
{
//东西
}
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 the entire function block with compiler directives:
I am using Nunit 2.5.6.10205.
#if !DEBUG
[Test]
public void MyReleaseOnlyTest()
{
// stuff
}
#endif
解决方案
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
}
这篇关于是否有NUnit的测试用例属性用于指定配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文