0

I want to run a Hello World MbUnit test within VS 2010, like below:

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. 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. It doesn't show all methods (Please refer to the screenshot below). I want something like running NUnit via ReSharper.

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.

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.

Below is the test result via Resharper test runner. As you can see on the Unit Test Session Window, I cannot see all the methods

Any idea would be appreciated.

enter image description here

Pingpong
  • 7,681
  • 21
  • 83
  • 209

1 Answers1

1

These are instruction for running MBUnit tests in Visual Studio 2012 and above using a neat NUnit trick.

Firstly, install the NUnit Test Adapter extension (yes, NUnit)

  • Tools > Extension and Updates > Online > search for NUnit > install NUnit Test Adapter.
  • You may need to restart the Visual Studio IDE.

Then, you simply need to add a new NUnit test attribute to your test methods. See example code here (notice the using statements at the top) ...

//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). You will need to stop Gallio from running the NUnit tests by deleting the NUnit folder in the gallio install location i.e. C:\Program Files\Gallio\bin\NUnit

Hope this helps, this is a simple working method so please vote up, many thanks.

Jay Byford-Rew
  • 5,736
  • 1
  • 35
  • 36