如何串行方式运行NUnit的测试夹具? [英] How to run NUnit test fixtures serially?

查看:160
本文介绍了如何串行方式运行NUnit的测试夹具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#/ NUnit的实施集成测试几套房。每个测试套件是一个单独的类,每个灯具安装程序创建和填充从脚本SQL Server数据库。这一切都与以前的ReSharper的5.1工作得很好。

I have several suites of integration tests implemented in C#/NUNit. Each test suite is a separate class, each fixture setup creates and populates a SQL Server database from scripts. This all used to work just fine prior to Resharper 5.1.

不幸的是,ReSharper的5.1开始在同一时间运行多个灯具。这是一个重大更改 - 他们都试图创建和填充相同的数据库,在混乱而这显然结束了。有什么办法,我可以有ReSharper的运行我的测试夹具串行?

Unfortunately, Resharper 5.1 begins to run several fixtures at the same time. This is a breaking change - they are all attempting to create and populate the same database, which obviously ends up in an mess. Is there any way I could have Resharper run my test fixtures serially?

如果没有,你会建议在同一时间连续运行我的NUnit的测试夹具,一台灯具?
在个别测试运行没有关系的顺序。

If not, what would you suggest to run my NUnit test fixtures serially, one fixture at a time? The order in which individual tests run does not matter.

推荐答案

我不知道是否有可能防止从ReSharper的并行运行试验;如果没有,下面的技巧可能的工作:用静态只读显示器成员创建一个静态类。然后,在 [TestFixtureSetUp] ,电话输入()在监视器上,并调用退出()显示器[TestFixtureTearDown] 。这样的话,只有一个测试夹具将被允许同时运行。不漂亮,但...

I don't know whether it is possible to prevent ReSharper from running tests in parallel; if not, the following hack might work: Create a static class with a static readonly Monitor member. Then, in [TestFixtureSetUp], call Enter() on the monitor, and call Exit() on the monitor in [TestFixtureTearDown]. That way, only one test fixture will be allowed to run at a time. Not pretty, though...

这篇关于如何串行方式运行NUnit的测试夹具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆