【问题标题】:Running MbUnit tests within Visual Studio 2010, ReSharper 6, TestDriven.NET在 Visual Studio 2010、ReSharper 6、TestDriven.NET 中运行 MbUnit 测试
【发布时间】:2023-03-24 07:07:01
【问题描述】:

我想在 VS 2010 中运行 Hello World MbUnit 测试,如下所示:

using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;

namespace ClassLibrary1
{
    [TestFixture]
    public class TestFixture1
    {
        [Test]
        public void Test()
        {
           Assert.AreEqual(1,2);
        }
        [Test]
        public void Test2()
        {
            Assert.AreEqual(1, 2);
        }
    }
}

我可以通过 ReSharper 测试运行程序和 TestDriven.Net 运行程序运行它们。 但结果只显示基本信息。

我通过 ReSharper 测试运行程序运行它们时遇到的问题是测试结果 Windows 中的结果仅显示测试数量。它没有显示所有方法(请参阅下面的屏幕截图)。我想要通过 ReSharper 运行 NUnit 之类的东西。

我通过TestDrive.Net测试运行器运行它们时遇到的问题是结果以文本模式显示在输出窗口中,这很难使用。

我想查看显示 VS Windows 中所有成功和失败的方法/类的测试结果,并能够导航到单击的方法,例如通过 ReSharper 运行 NUnit。

以下是通过 Resharper 测试运行器的测试结果。正如您在单元测试会话窗口中看到的,我看不到所有方法

任何想法都将不胜感激。

【问题讨论】:

    标签: c# visual-studio-2010 mbunit testdriven.net resharper-6.0


    【解决方案1】:

    这些是在 Visual Studio 2012 及更高版本中使用简洁的 NUnit 技巧运行 MBUnit 测试的说明。

    首先,安装 NUnit 测试适配器扩展(是的,NUnit)

    • 工具 > 扩展和更新 > 在线 > 搜索 NUnit > 安装 NUnit 测试适配器。
    • 您可能需要重新启动 Visual Studio IDE。

    然后,您只需向您的测试方法添加一个新的 NUnit 测试属性。在此处查看示例代码(注意顶部的 using 语句)...

    //C# example
    using MbUnit.Framework;
    using NuTest = NUnit.Framework.TestAttribute;
    
    namespace MyTests
    {
        [TestFixture]
        public class UnitTest1
        {
            [Test, NuTest]
            public void myTest()
            {
                //this will pass
            }
        }
    }
    

    您可以在 Visual Studio 中作为 NUnit 运行和调试测试,而 Gallio Icarus GUI Test Runner 将作为 MBUnit 运行它们(例如,启用并行运行)。您需要通过删除 Gallio 安装位置(即 C:\Program Files\Gallio\bin\NUnit)中的 NUnit 文件夹来阻止 Gallio 运行 NUnit 测试

    希望这有帮助,这是一个简单的工作方法,所以请投票,非常感谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多