开发者

How to debug unit tests that use Microsoft Moles framework

Our team is working on writing unit tests for a .Net project. We use “Visual St开发者_如何学JAVAudio 2010” IDE, “NUnit” (v. 2.5.9) unit-testing framework, and “Microsoft Moles” type-isolating framework.

We have encountered a problem: we couldn’t debug unit tests that use Moles (while tests that don’t use it are debugged with no problems). Tests that use Moles are failed with the following error message:

Microsoft.Moles.Framework.Moles.MoleInvalidOperationException : Moles requires tests to be IN an instrumented process.

Does anyone have ideas why debugging of those tests not working?

Thanks in advance!


From the Moles Manual:

Assembly

Microsoft.Moles.NUnit.dll You will have to register that add-in with NUnit by copying the Microsoft.Moles.NUnit.dll assembly in the NUnit bin/addins folder.

NUnit Version

2.5.2.9222 (for other NUnit versions, recompile the attribute from sources)

Example Usage

using NUnit.Framework; 
using Microsoft.Moles.Framework.NUnit;
[TestFixture]
public class NUnitTest
{
    [Test]
    [Moled] // set up of the mole context around the test case
    public void TestWithMoles() {
        ...
    }

    // alternative not using [Moled]
    [Test]
    public void TestWithMoles() {
        using(MolesContext()) { // clears moles leaving context
            ...
        } 
    }
}

Command Line

Make sure you use the /domain=None argument when invoking the NUnit console runner.

moles.runner.exe /r:nunit-console.exe /args=”/domain=None” ..
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜