[翻译]NUnit---Explicit and Ignore Attributes(十二)
2013-06-12 10:28
495 查看
ExplicitAttribute (NUnit 2.2)
除非显示选择执行,Explicit特性会忽略执行test or test fixture。在GUI选择test or fixture,在控制台命令行指定了要执行的fixture名称或者包含Category特性的fixture才会执行。可选字符串参数可用于给定标记显示测试的原因。
如果指定了Explicit特性的test or fixture在执行的测试用例中,除非通过上面的方式选定否则会忽略。测试用例完全不会影响输出结果,像ignored一样,甚至不会计入测试用例数量。在GUI,测试用例树节点保持灰色,并且不会影响状态条。
Note:在NUnit2.4之前,这些测试用例被忽略掉(ignored)。
Test Fixture Syntax
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture, Explicit] public class ExplicitTests { // ... } }
Test Syntax
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture] public class SuccessTests { [Test, Explicit] public void ExplicitTest() { /* ... */ } }
IgnoreAttribute (NUnit 2.0)
ignore特性用于在一段时间内不执行一个 test or test fixture。当用Ignore特性标记一个Test or a TestFixture时,运行的程序会识别这个特性并且不会执行这些测试用例。如果一个测试用例没有执行程序条会变为黄色,并且在测试输出中指出它未执行。这个功能应该用于临时不执行test or fixture。相对于注释掉测试用例或者重命名,这是更好的机制。由于测试用例会和其他的代码一起编译,在运行时会有迹象显示未执行。这确保测试不会被遗忘。
Test Fixture Syntax
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture] [Ignore("Ignore a fixture")] public class SuccessTests { // ... } }
Test Syntax
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture] public class SuccessTests { [Test] [Ignore("Ignore a test")] public void IgnoredTest() { /* ... */ } }
相关文章推荐
- [翻译]NUnit---Maxtime and Ignore and Platform Attributes(十三)
- [翻译]NUnit---Category and Combinatorial Attributes(九)
- [翻译]NUnit---Property and Random Attributes(十四)
- [翻译]NUnit---TearDown and SetUpFixture and Test Attributes(二十)
- [翻译]NUnit---SetUp and SetUpFixture and Suite Attributes(十九)
- [翻译]NUnit---Sequential and SetCulture and SetUICulture Attributes(十八)
- [翻译]NUnit---Culture and Datapoint Attributes(十)
- 用NUnit为.NET程序做测试 --- 常用测试属性之二 Ignore, Explicit
- Object-Oriented Analysis and Design Using UML 翻译与学习 (十二)
- [翻译]NUnit---Action Attributes(八)
- [翻译]NUnit---Action Attributes(八)
- [翻译]SQL Server And XML: FOR XML EXPLICIT - Part 1
- [翻译]SQL Server And XML: FOR XML EXPLICIT - Part 2
- Boost.Interprocess使用手册翻译之十二.架构和内部实现(Architecture and internals)
- [翻译]SQL Server And XML: FOR XML EXPLICIT - Part 3
- Boost.Interprocess使用手册翻译之十二.架构和内部实现(Architecture and internals)
- 待翻译---- Understanding Spring MVC Model and Session Attributes
- 《Practical WPF Charts and Graphics 》翻译——之八
- Bridging Collaborative Filtering and Semi-Supervised Learning:paper翻译与解读
- Android Custom Views and XML attributes