开发者

Is it possible to have MSpec & NUnit tests in a single project?

开发者 https://www.devze.com 2022-12-29 05:47 出处:网络
I\'ve got a unit test project using NUnit. When I add the mspec (machine.specifications) assembly to the references, both ReSharper and TestDriven.Net stop running the NUnit tests and only run the msp

I've got a unit test project using NUnit. When I add the mspec (machine.specifications) assembly to the references, both ReSharper and TestDriven.Net stop running the NUnit tests and only run the mspec tests.

Is there a way or setting that allows both NUnit & mspec tests to co-exist and run开发者_运维问答 in the same project using R# & TD.Net test runners?


I've just tested this on VS 2008 with ReSharper 5.0 and TestDriven.Net 3.0 RC2 and the following code.

using Machine.Specifications;

using NUnit.Framework;

namespace ClassLibrary1
{
    [TestFixture]
    public class FooTests
    {
        [Test]
        public void Bar()
        {
            Assert.IsTrue(true);
        }
    }

    public class When_tests_are_run
    {
        It should_succeed = () => true.ShouldBeTrue();
    }
}

I cannot reproduce the behavior you describe with the ReSharper. First off, ReSharper detects both test classes as indicated by the green-and-yellow gutter marks. Right-clicking on the project and selecting "Run Unit Tests" runs both tests successfully. Running them individually via the gutter icons also works as expected.

As for TestDriven.Net, I'm not sure whether it supports scenarios where multiple test frameworks are used within one project. When I "Run Test(s)" on the project, only the MSpec context is executed. However, "Run Test(s)" while clicking inside the NUnit TestFixture executes the NUnit test.


Make sure you turn on MSpec in ReSharper. Even if you "installed" the runner (by hand or by bat file), it's not turned on by default. Turn it on at

ReSharper menu | Options... | Tools | Unit Testing

0

精彩评论

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

关注公众号