开发者

Nunit not releasing a DLL used in a test / can't delete in teardown

I have an application which has to inter开发者_Go百科face with an unmanaged, and frankly buggy, DLL.

I've compensated for this by making my application check for all sorts of error conditions on running the DLL, things like timing out in case the DLL has gone into an infinite loop.

I'm trying to test that handling in my application, and so I've deliberately coded a DLL which goes into an infinite loop on purpose.

In my unit test, I want to rename the original DLL, copy in my 'broken' DLL, run the test, see the timeout code work, then remove the broken DLL and replace the original DLL.

However, in my TearDown method I can't delete the DLL, getting an UnauthorizedAccessException. I presume this is because nUnit still has the DLL 'open' in some way.

How can I make nUnit release the DLL?


Well, I worked around it by splitting the troublesome tests into separate assemblies. I now have 3 test assemblies, 1 containing the bulk of the tests, and 1 containing each of the tests I was having trouble with. Both of those tests include SetUp and TearDown code to remove any clutter that may have been left by the other test.

So, I still don't know how to release the DLL, but by moving the tests out into separate assemblies I no longer need to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜