RequiresSTAAttribute (NUnit 2.5)

  RequiresSTA特性用于测试方法、类、程序集中指定测试应该在单线程中运行。如果父测试不在单线程中运行则会创建一个新的线程。

Note:

  在测试方法上也可以使用STAThread特性。尽管运行时指挥在执行程序集的入口识别这个特性,但是许多用户希望再测试上工作,所以我们把它作为一个同义词。

Examples

// An STA thread will be created and used to run
// all the tests in the assembly
[assembly:RequiresSTA] ... // TestFixture requiring a separate thread
[TestFixture, RequiresSTA]
public class FixtureRequiringSTA
{
// An STA thread will be created and all
// tests in the fixture will run on it
// unless the containing assembly is
// already running on an STA Thread
} [TestFixture]
public class AnotherFixture
{
[Test, RequiresSTA]
public void TestRequiringSTA()
{
// A separate thread will be created for this test
// unless the containing fixture is already running
// in the STA.
}
}

See also...

  • RequiresThreadAttribute
  • RequiresMTAAttribute

RequiresThreadAttribute (NUnit 2.5)

  RequiresThread特性指示一个测试方法、类或者程序集应该在一个独立的线程中运行。还可以在构造函数中指定需要的线程。

Note:这个特性经常和ApartmentState参数一起使用,配合使用来创建一个新的线程。如果不合适用ApartmentState来创建线程,还还可以使用RequiresSTA特性或者RequiresMTA特性。

Examples

// A thread will be created and used to run
// all the tests in the assembly
[assembly:RequiresThread] ... // TestFixture requiring a separate thread
[TestFixture, RequiresThread]
public class FixtureOnThread
{
// A separate thread will be created and all
// tests in the fixture will run on it.
} [TestFixture]
public class AnotherFixture
{
[Test, RequiresThread]
public void TestRequiringThread()
{
// A separate thread will be created for this test
} [Test, RequiresThread(ApartmentState.STA)]
public void TestRequiringSTAThread()
{
// A separate STA thread will be created for tnis test.
}
}

See also...

  • RequiresSTAAttribute
  • RequiresMTAAttribute

[翻译]NUnit---RequiresSTA and RequiresThread Attributes(十七)的更多相关文章

  1. [翻译]NUnit---Action Attributes(八)

    Attributes NUnit 1.0使用传统的基于继承和命名约定来识别测试.从2.0开始NUnit使用自定义特性来实现. 因为NUnit的test fixtures不是从框架类库继承,所以开发人员 ...

  2. 最适合入门的Laravel中级教程(三)表单验证

    做开发有个原则是永远不能信任用户输入的数据: 即便前端已经做了验证: 在后端 php 也必须要再次验证: laravel 为表单验证提供了强大且简单的方案: 创建示例路由: routes/web.ph ...

  3. [翻译]NUnit---Property and Random Attributes(十四)

    小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...

  4. Gradle 1.12用户指南翻译——第四十七章. Build Init 插件

    本文由CSDN博客貌似掉线翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...

  5. Gradle 1.12 翻译——第十七章. 从 Gradle 中调用 Ant

    有关其他已翻译的章节请关注Github上的项目:https://github.com/msdx/gradledoc/tree/1.12,或访问:http://gradledoc.qiniudn.com ...

  6. Gradle 1.12用户指南翻译——第二十七章. Ear 插件

    其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Github上的地址: https://g ...

  7. Gradle 1.12用户指南翻译——第三十七章. OSGi 插件

    本文由CSDN博客万一博主翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...

  8. [翻译]NUnit---SetUp and SetUpFixture and Suite Attributes(十九)

    SetUpAttribute (NUnit 2.0 / 2.5) 本特性用于TestFixture提供一个公共的功能集合,在呼叫每个测试方法之前执行.同时也用在SetUpFixture中,SetUpF ...

  9. 第十七周翻译-SQL Server中事务日志管理的阶梯,级别5:以完全恢复模式管理日志

    SQL Server中事务日志管理的阶梯,级别5:以完全恢复模式管理日志 作者:Tony Davis,2012/01/27 翻译:赖慧芳 译文: 该系列   本文是Stairway系列的一部分:SQL ...

随机推荐

  1. JDK-8不是有效的Win32应用程序

  2. 一些unity问题的收集

    ---恢复内容开始--- 1.Mono打不开且鼠标点击标签页无反应的解决办法 http://answers.unity3d.com/questions/574157/monodevelop-not-o ...

  3. UVa 1592 Database(巧用map)

    Peter studies the theory of relational databases. Table in the relational database consists of value ...

  4. E0443类模板 "std::unordered_set" 的参数太多

    1>------ 已启动全部重新生成: 项目: QtGuiApplication20190416, 配置: Debug x64 ------1>Uic'ing QtGuiApplicati ...

  5. iOS - OC - 打印信息 - xcode 中文打印

    #import <Foundation/Foundation.h> @implementation NSDictionary (Log) //重写系统的方法控制输出 -(NSString ...

  6. struts框架问题四之获取到值栈的对象

    4. 问题四 : 如何获得值栈对象 * 获得值栈对象 有三种方法 * ValueStack vs1 = (ValueStack) ServletActionContext.getRequest().g ...

  7. PL/Sql快速执行 insert语句的.sql文件

    当全是 insert语句的.sql文件太大时(insert 语句条数太大),直接打开执行sql文件,pl/sql会卡死. 这是可以用pl/sql的命令窗口来执行.sql文件,操作步骤如下: 1.新建命 ...

  8. Nginx 分析access日志文件

    Nginx Access Log日志统计分析常用命令 IP相关统计 统计IP访问量 awk '{print $1}' access.log | sort -n | uniq | wc -l 查看某一时 ...

  9. DB2事务日志

    1.DB2数据库的日志原理 事务日志记录数据库中所有对象和数据的改变,在早前版本中最大可达256G,其大小为( logprimary + logsecond ) * logfilsiz,其中logpr ...

  10. MapReduce 计算模式

    声明:本文摘录自<大数据日知录——架构与算法>一书. 较常见的计算模式有4类,实际应用中大部分ETL任务都可以归结为这些计算模式或者变体. 1.求和模式 a.数值求和 比如我们熟悉的单词计 ...