`

[翻译]NUnit---Maxtime and Ignore and Platform Attributes(十三)

阅读更多
原帖地址:http://www.cnblogs.com/kim01/archive/2013/06/13/3131342.html

Maxtime特性用于测试方法指定测试用例执行的最大时间(单位:秒)。如果测试用例花费比指定更长的时间来完成测试会被报告为失败。


Example



[Test, Maxtime(2000)]
public void TimedTest()
{
...
}


Notes:


  1.任何断言失败会优先级比超时检查高。


  2.如果时间超时,这个特性也不会取消测试用例。仅仅是等待完成测试用例,然后比较运行时间和指定的最大时间。如果希望取消长时间运行的测试用例,参考 TimeoutAttribute


PairwiseAttribute (NUnit 2.5)


Pairwise特性用在测试上指定NUnit生成所有可能值对的测试用例。在处理包含超过两个功能的测试组合激增时的常用方法。


Note:在目前的Alpha版本会接受这个特性,但是会忽略掉,数据项会使用默认组合方法类组合。 


PlatformAttribute (NUnit 2.2.2)


Platform特性用于指定test or fixture执行的平台。使用区分大小写字符串值来指定平台,并且可以使用Include or Exclude属性来包含或者排除执行的平台。通过在Platform特性的构造函数中包含指定的参数来确定平台。在任何情况下,可以使用多个逗号来分隔值。


如果包含Platform特性的test or fixture没有满足指定的平台则会被忽略掉。测试不会影响输出:它被忽略掉甚至不会计入测试总数中。在GUI,测试用例树节点保持为灰色,并且不会影响状态栏颜色。


Note:NUnit2.4之前的版本,测试用例会被忽略


Test Fixture Syntax



namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
[Platform(
"NET-2.0")]
public class DotNetTwoTests
{
// ...
}
}


Test Syntax



namespace NUnit.Tests
{
using System;
using NUnit.Framework;

[TestFixture]
public class SuccessTests
{
[Test]
[Platform(Exclude
="Win98,WinME")]
public void SomeTest()
{
/* ... */ }
}


Platform Specifiers


Platform特性用来指定 test or fixture要执行的平台。Platforms会通过区分大小写字符串来指定平台,还可以分别使用Include or Exclude属性来包含或者排除要运行的平台。


Note:在NUnit2.4之前,这些测试用例会被忽略掉。


The following values are recognized as platform specifiers. They may be expressed in upper, lower or mixed case.



 


Notes:



  1. Includes Net-2.0

  2. Includes Net-2.0 and Net-3.0

  3. Includes Net-4.0

  4. Includes Mono-2.0

  5. Includes Mono-2.0 and Mono-3.0

本文链接

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics