Gallio test runner plugin to Visual Studio 2008 and 2010 for MBUnit tests

两盒软妹~` 提交于 2019-12-04 03:25:14

TestDriven.Net works really well. Gallio also supports the ReSharper unit test runner and Visual Studio test tools. We will be shipping a new release of Gallio this week with support for R# 5.0 and VS 2010.

Lee Oades

Install Gallio 3.1 on the dev machine. Then in VS2008, you'll have the option to create a "MbUnit v3 Test Project". This doesn't just include all of the Gallio dlls for you, it has a magic line in the project which identifies it to VS as a Test project.

You can now just use the in-built VS2008 Test runner.

If you have any existing projects with unit tests in, rather than making new projets, edit your existing project file and add the following line on line 9 (underneath the <ProjectGuid> on line 8):

 <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

(If you have a VB project, it has a different second GUID: <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids> You can find the correct values by creating a new MbUnit test project from the templates installed with Gallio and then looking at the project file (.csproj or .vbproj) in a text editor.)

Now when you reload the project, VS2008 will recognise it as a test project.

A distinct advantage that I found over using Icarus was that debugging is now far more straight forward with break points being hit as expected.

Good Luck, Lee

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!