简体   繁体   English

在Visual Studio 2010,ReSharper 6,TestDriven.NET中运行MbUnit测试

[英]Running MbUnit tests within Visual Studio 2010, ReSharper 6, TestDriven.NET

I want to run a Hello World MbUnit test within VS 2010, like below: 我想在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);
        }
    }
}

I can run them via ReSharper test runner, and TestDriven.Net runner. 我可以通过ReSharper测试运行程序和TestDriven.Net运行程序运行它们。 But the result only show basic information. 但是结果仅显示基本信息。

The problem I am having when running them via ReSharper Test runner is that the result in test result Windows ONLY show the number of tests. 通过ReSharper Test运行程序运行它们时,我遇到的问题是测试结果Windows中的结果仅显示测试数量。 It doesn't show all methods (Please refer to the screenshot below). 它不会显示所有方法(请参阅下面的屏幕截图)。 I want something like running NUnit via ReSharper. 我想要通过ReSharper运行NUnit之类的东西。

The problem I am having when running them via TestDrive.Net Test runner is that the result is shown in the Output window in text mode, which is difficult to use. 通过TestDrive.Net测试运行程序运行它们时,我遇到的问题是,结果在文本模式下的“输出”窗口中显示,这很难使用。

I want to see test results that shows all successful and failed methods/classes within VS Windows, and be able to navigate to the clicked method, something like running NUnit via ReSharper. 我想查看测试结果,该结果显示VS Windows中所有成功和失败的方法/类,并能够导航到单击的方法,类似于通过ReSharper运行NUnit。

Below is the test result via Resharper test runner. 以下是Resharper测试运行程序的测试结果。 As you can see on the Unit Test Session Window, I cannot see all the methods 如您在单元测试会话窗口中看到的,我看不到所有方法

Any idea would be appreciated. 任何想法将不胜感激。

在此处输入图片说明

These are instruction for running MBUnit tests in Visual Studio 2012 and above using a neat NUnit trick. 这些是使用整洁的NUnit技巧在Visual Studio 2012及更高版本中运行MBUnit测试的说明。

Firstly, install the NUnit Test Adapter extension (yes, NUnit) 首先,安装NUnit测试适配器扩展(是的,NUnit)

  • Tools > Extension and Updates > Online > search for NUnit > install NUnit Test Adapter. 工具>扩展和更新>联机>搜索NUnit>安装NUnit测试适配器。
  • You may need to restart the Visual Studio IDE. 您可能需要重新启动Visual Studio IDE。

Then, you simply need to add a new NUnit test attribute to your test methods. 然后,您只需要在测试方法中添加一个新的NUnit测试属性即可。 See example code here (notice the using statements at the top) ... 请参阅此处的示例代码(请注意顶部的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
        }
    }
}

You can run and debug the test in visual studio as NUnit and Gallio Icarus GUI Test Runner will run them as MBUnit (enabling parallel runs for example). 您可以在Visual Studio中运行和调试测试,因为NUnit和Gallio Icarus GUI Test Runner将它们作为MBUnit运行(例如,启用并行运行)。 You will need to stop Gallio from running the NUnit tests by deleting the NUnit folder in the gallio install location ie C:\\Program Files\\Gallio\\bin\\NUnit 您需要通过删除gallio安装位置中的NUnit文件夹(即C:\\ Program Files \\ Gallio \\ bin \\ NUnit)来阻止Gallio运行NUnit测试。

Hope this helps, this is a simple working method so please vote up, many thanks. 希望这会有所帮助,这是一种简单的工作方法,因此请投票,非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM