[翻译]NUnit---RequiresSTA and RequiresThread Attributes(十七)
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(十七)的更多相关文章
- [翻译]NUnit---Action Attributes(八)
Attributes NUnit 1.0使用传统的基于继承和命名约定来识别测试.从2.0开始NUnit使用自定义特性来实现. 因为NUnit的test fixtures不是从框架类库继承,所以开发人员 ...
- 最适合入门的Laravel中级教程(三)表单验证
做开发有个原则是永远不能信任用户输入的数据: 即便前端已经做了验证: 在后端 php 也必须要再次验证: laravel 为表单验证提供了强大且简单的方案: 创建示例路由: routes/web.ph ...
- [翻译]NUnit---Property and Random Attributes(十四)
小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...
- Gradle 1.12用户指南翻译——第四十七章. Build Init 插件
本文由CSDN博客貌似掉线翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...
- Gradle 1.12 翻译——第十七章. 从 Gradle 中调用 Ant
有关其他已翻译的章节请关注Github上的项目:https://github.com/msdx/gradledoc/tree/1.12,或访问:http://gradledoc.qiniudn.com ...
- Gradle 1.12用户指南翻译——第二十七章. Ear 插件
其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Github上的地址: https://g ...
- Gradle 1.12用户指南翻译——第三十七章. OSGi 插件
本文由CSDN博客万一博主翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...
- [翻译]NUnit---SetUp and SetUpFixture and Suite Attributes(十九)
SetUpAttribute (NUnit 2.0 / 2.5) 本特性用于TestFixture提供一个公共的功能集合,在呼叫每个测试方法之前执行.同时也用在SetUpFixture中,SetUpF ...
- 第十七周翻译-SQL Server中事务日志管理的阶梯,级别5:以完全恢复模式管理日志
SQL Server中事务日志管理的阶梯,级别5:以完全恢复模式管理日志 作者:Tony Davis,2012/01/27 翻译:赖慧芳 译文: 该系列 本文是Stairway系列的一部分:SQL ...
随机推荐
- linux - 文件拆分
核心: split 例如,把一个文件以10万行为单位拆分文件, 并且以perfix作为前缀,3位数数字,从000开始递增 split -l 100000 filename.txt -d -a 3 pe ...
- AtomEye的使用
网易博客粗略地在转载的基础上对AtomEye补充了概述: AtomEye: Atomistic configuration viewer developed by J. Li. This progra ...
- IDEA 工具下导出文件及文件的目录结构插件
idea导出增量补丁插件 有时候需要导出IDEA的文件目录结构,即导出 指定修改后的JAVA文件编译后的CLASS .或者是修改过的jsp.配置文件等, 装载此插件,即可以完成导出文件 及文件的目 ...
- struts框架值栈问题二之值栈的内部结构
2. 问题二 : 值栈的内部结构 ? * 值栈由两部分组成 > root -- Struts把动作和相关对象压入 ObjectStack 中--List > context -- Stru ...
- C#设计模式之简单工厂模式(过渡模式)
一.引言 之所以写这个系列,是了为了自己更好的理解设计模式,也为新手提供一些帮助,我都是用最简单的.最生活化的实例来说明.在上一篇文章中讲解了单例模式,今天就给大家讲一个比较简单的模式——简单工厂模式 ...
- 前端之css笔记2
1 属性选择器 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- oracle 用一个表的一个字段更新另一个表的一个字段
案列: 想更新A表的name字段,由于失误,在写这个表的时候,这个字段没有写,发现的时候,已经写了一个多月的数据了.改了之后的过程,会正常的写这个字段, 可是已经写了的数据也不能铲了,重新计算. 好在 ...
- idea开发工具下报Set language level to 6-@Override in interfaces的解决方法
idea开发工具下报Set language level to 6-@Override in interfaces的解决方法 实现接口时报如下错误:Set language level to 6-@O ...
- Django入门与实践-第14章:用户注册(完结)
http://127.0.0.1:8000/signup/ django-admin startapp accounts INSTALLED_APPS = [ 'accounts', ] # mypr ...
- Ubuntu 16.04安装MySQL及遇到的问题解决方案
使用以下命令即可进行MySQL安装: sudo apt-get install mysql-server 上述命令会安装以下包: apparmor mysql-client-5.7 mysql-com ...