在不同的应用程序域与NUnit的运行单元测试 [英] Run unit tests in different appdomain with NUnit

查看:217
本文介绍了在不同的应用程序域与NUnit的运行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎有一个问题,我们正在使用的应用程序使用Ninject内核,并包含一个与WCF调用(用户名,令牌......)的内容聚集了特定的配置。

I seem to be having an issue, the application we're using uses a Ninject kernel, and contains a particular configuration that's gathered with contents of the WCF call (username, token...).

根据一个特定配置中的用户被分配于该应用的权利,这是通过在Ninject内核的特定实例屏蔽

Based on that a particular configuration the user is assigned rights on the app, this is shielded through a particular instance in the Ninject kernel.

我们不能只重新构图Ninject内核,我们想要做的是运行了几个NUnit的测试什么,但在一个单独的应用程序域中运行他们每个人(重建每次用不同的设置内核)。

We cannot just recompose the Ninject kernel, what we'd like to do is run a couple of Nunit tests, but run each of them in a separate app domain (recreating the kernel each time with different settings).

我只找到方法,在不同的应用程序域整个测试项目,但每次测试不考。

I've only found ways to run whole test projects in different app domains but not test per test.

有没有办法解决这个问题的方法吗?

Is there a way to solve this?

不幸的是,Ninject配置不站在我们这边,我们以'活'用这种方式。

Unfortunately the Ninject configuration is not on our side, we have to 'live' with it this way.

推荐答案

我不认为这是解决这个问题,而不NUnit的代码重写部分的方法。它已经有一段时间我一直在NUnit的代码中,但我敢肯定的主要应用程序域装载部分并没有改变。

I don't think there is a way to solve it without re-writing parts of the NUnit code. It has been a while since I've been inside the NUnit code, but I am pretty sure the main app domain loading part has not changed.

NUnit的通常使用两个应用程序域。运行NUnit的时创建的默认之一,并单独的一个加载测试组件和它们引用的程序集。它是在这样做是为了让试件的卸载主要原因。你不能卸载一个dll,但你可以卸载一个AppDomain。

NUnit typically uses two app domains. The default one that is created when NUnit is run and a separate one to load the test assemblies and the assemblies they reference. It's main reason in doing this is to allow the unloading of the test assemblies. You can't unload a dll, but you can unload an appdomain.

您可能能够运行NUnit的每个测试一次,通过在命令行上的测试,但这是丑陋,我不知道它会有所帮助。

You might be able to run NUnit once per test and pass the test on the command line, but that's ugly and I'm not sure it will help.

也有可能利用的 action属性在NUnit的2.6,但你会做了很多工作,在那里做

It might also be possible to leverage Action Attributes in NUnit 2.6, but you are going to do a lot of work in there to do it.

您也许还能在你的安装方法创建一个新的应用领域,并调用到它在每个测试。尴尬,但可能的。

You might also be able to create a new app domain in your setup method and call into it in each test. Awkward but possible.

我很抱歉,我没有一个更完整的答案。

I'm sorry I don't have a more complete answer.

这篇关于在不同的应用程序域与NUnit的运行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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