[翻译]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 ...
随机推荐
- Unity即将内置骨骼动画插件Anima2D
Unity一直在寻找新的方法来帮助开发者,并为他们提供最好的工具.在此我们向大家宣布,Unity将内置流行的骨骼动画插件Anima2D,从2017年1月开始免费供所有Unity开发者使用! 同时也欢迎 ...
- LSTM Accuracy
Training iter #1: Batch Loss = 1.234543, Accuracy = 0.29866665601730347PERFORMANCE ON TEST SET: Batc ...
- [leetcode]283. Move Zeroes移零
Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...
- C# Socket网络编程精华篇
我们在讲解Socket编程前,先看几个和Socket编程紧密相关的概念: TCP/IP层次模型 当然这里我们只讨论重要的四层 01,应用层(Application):应用层是个很广泛的概念,有一些基本 ...
- 【深度好文】多线程之WaitHandle-->派生-》Mutex信号量构造
bool flag = false; System.Threading.Mutex mutex = new System.Threading.Mutex(true, "Test", ...
- ubuntu自动拉黑破解ssh服务的IP
2013年的脚本,今天拿出来备份一下. vim /root/secure_ssh.sh #!/bin/bash cat /var/log/auth.log|awk '/Failed/{print $( ...
- 在iframe框架中全屏不好使的原因
遇到的问题:我是在iframe框架中添加了一个插件在360和火狐中不好使,将allowfullscreen="true" 属性配置好就没问题了: 可能出现的原因:将allowful ...
- 使用PHP-GTK编写一个windows桌面应用程序
PHP-GTK的下载地址:http://gtk.php.net/download.php?language=en-US, 猿哥选择了最新版本(beta版),可能有人会问我们为啥不选最新的stable版 ...
- Luogu 3959 [NOIP2017] 宝藏- 状压dp
题解 真的想不到这题状压的做法...听说还有跑的飞快的模拟退火,要是现场做绝对滚粗QAQ. 不考虑深度,先预处理出 $pt_{i, S}$ 表示让一个不属于 集合 $S$ 的 点$i$ 与点集 $S$ ...
- bluez蓝牙测试工具
http://blog.csdn.net/talkxin/article/details/50610984