How does MbUnit work with VS 2008 - visual-studio

I set up MbUnit and have been trying to get it to work with VS 2008 using the MbUnit GUI but every time I run a test it closes and I get a this program needs to close error.
I had a similar problem with Gallio where I got a runner exception every time I ran a test.
Do I need an addin for VS like testDriven.Net to get this to work?

Same here. TestDriven.Net really makes things slick and easy. Right-click on a test and run it... MBUnit integrates fine with that add-in.

You don't need TestDriven.Net but it sure helps.
When you say you use the MBUnit GUI "but every time I run a test it closes..." do you mean that MBUnit closes or VS2008? If is MBUnit, then perhaps there is something wrong with your installation. If it is VS2008, then something is fishy since MBunit shouldn't cause VS2008 to crash.
I've used (though I've stopped and now use NUnit) MBUnit with TestDriven.Net and VS2005 with great success.

I'd recommend testdriven.net for a free tool, and ReSharper as a better tool for running MbUnit tests.
The Gallio test running shouldn't be crashing on you like that, there is a problem somewhere.

I'm using combination of Visual Studio 2008, ReSharper 4.1 and latest builds of Gallio. With that it works pretty well.

Related

VS2010 Unit test “Pending” and the test cannot be completed

I'm using VS2010 (with windows 7).
Every time I try to run a unit test it stays on "Pending" and the test cannot be completed.
I tried to follow this msdn instructions.
I tried debugging test method (test view/debug selection), set breakpoints, but VS2010 indicates: the breakpoint will not currently be hit... I'm in debug configuration.
Any advice?
If you have VS2010 and VS2012 installed on the same box you need to install SP1 for VS2010 or the unit tests sometimes won't work. (SP1 available here.)
Try to do a clean solution (right click solution and clean). And then do a rebuild. That should solve the problem.

Resharper 6 simply ignores all my tests

I have a solution with a lot of nunit tests in different projects. When I run resharpers testrunner, it finds all the tests. But when it comes to execution it simply marks them all as grey and silently completes.
How do I figure out whats wrong with the testrunner, and most importantly how do I get it to run my tests.
I have resharper 6 in visual studio 2008. My code is on a fileshare, and everything runs in a virtual machine.
Jetbrains has confirmed this to be a bug. That resharper wont run nunit tests located on a networkshare. They'll try to fix it in 6.1.
You can find the ticket here:
http://youtrack.jetbrains.net/issue/RSRP-275538

How to set a breakpoint in a Nunit test and step through with Visual WebDeveloper 2008?

I have written a NUnit test in Visual Web Developer 2008 Express. But when I run the test, it doesn't pause at the breakpoint I had set. It just keeps on running but at the breakpoint, I need a step-by-step view on the test.
Could anyone please tell me how I can use breakpoints with NUnit?
Thanks in advance!
This is how you do it... - http://codebetter.com/blogs/paul.laudeman/archive/2004/03/18/NUnit-Tip_3A00_-Debugging-your-unit-tests.aspx
However I'm not sure if Express editions of VS support 'start external program' for debugging / 'attaching to a process'. In which case, you may need to upgrade to be able to debug.
This is easily done with VS C# Express - have a look at:
http://www.dotnet-developer.de/2009/10/aspnet2005/how-to-use-nunit-with-visual-studio-express-2008/
However I don't know if this will apply to Web Developer.
I assume you are running NUnit from outside Visual Studio, since the Express versions do not support Plugins. I don't think you can debug NUnit tests that way. If you had a non-Express version you could use the testdriven.net-plugin for debugging. Maybe if you set the NUnit runner as program to execute on debugging with you assembly as command line parameter...

How can I get started using Nunit in my Visual Studio project?

I want to start using Nunit (finally), I am using Visual Studio 2008.
Is it as simple as importing Nunit into my test project?
I remember seeing a GUI for NUnit, does that do the exact same thing that a separate test project would do, except show you the pass/fail visually?
I like to add a link to NUnit in my external tools.
Under Tools->External Tools add NUnit
Title: &NUnit
Command: <path to nunit>
Arguments $(ProjectFileName) /run
Initial directory: $(ProjectDir)
After that you can quickly run it by compiling then hitting alt-t + n
Yes, that's basically it. Personally I find the unit test runner which comes with ReSharper to be excellent - and the tool itself is well worth the licence feel. Alternatively there's TestDriven.NET.
Having a test project which runs nunit-gui or nunit-console separately is all very well, but you really want the whole unit testing experience to be as seamless as possible. The easier it is to write and run tests, the more likely you are to do it - which is a very good thing. Don't underestimate the gradual build-up of frustration due to a slightly poorer user experience, flipping between windows etc.
NUnit is something that isn't inside Visual Studio 2008. It does have a console OR a graphical user interface (gui) that can be run both outside VS2008 OR can be attached to the process of VS2008 for debugging.
If you do want something inside VS2008 you need to have a third party pluging like ReSharper.
Edit: This has been answered in the past (not for VS2008 specificly but still relevant)
I've used TestDriven.NET with VS2005, and it has changed how I develop and test code.
You can run all of the tests on any class, module, project, or solution. You can also run a test in the debugger, which is tremendously useful to diagnose and fix issues when they crop up.
The GUI is nice, but if you run your tests often, you'll probably abandon it for a faster/integrated runner.
In any case, you have some options on how to run your tests:
NUnit.Gui.Exe -- you can run this & select your test project dll to run the tests. While it is open it will refresh when you build, so you can ALT-TAB to it & re-run your tets. Another technique I've seen is to set this application as the startup program for your test project. Then set your test project as the startup project and push F5.
Download & use TestDriven.net. This is fast and lets you run tests from a right click menu, while you're sitting on a test or at a node in the solution explorer. This is what I use mostly. I have it mapped to CTRL+T for quick access.
Resharper has a test runner as well. This gives you the GUI with red/green lights inside of visual studio. It also gives you a little icon next to each of your tests to quickly run them.
You can use the plugin NUnitForVS that is available here: http://www.codeplex.com/NUnitForVS
This integrates the test running and results in your VS 2008 IDE. We've been using it for a couple of months and it's working well for us.
You should also remember that with VS 2008 professional you can use the MS Unit testing tool that was previously only available in the team versions.
You can run it as external program, but as for me it is not very nice. I like, when test starts within the VS. So, if you have ReSharpe you can go to Tools -> Options -> Environment -> Keyboard and set the hot key for ReSharper_UnitTest_ContextRun. I set it to Ctrl + t.
I attach my nunit console program to the Post-build event so every time I build my project the tests are run without the need for third party tools (apart from NUnit). I'm using Visual Studio 2010, but I am pretty sure you can achieve the same behaviour in Visual Studio 2008.
To do this:
Open the project's properties window (the project containing the tests)
In the Post-build event command line add the line:
"C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console-x86.exe" "$(TargetDir)$(TargetFileName)"
Build the project and the output should be written to the Ouptput window (Build). It's important to choose the x86 version of the console runner.

Is there a free Visual Studio addin for Nunit?

I'm cheap and don't want to pay for ReSharper or TestDriven.NET, is there a free visual Studio addin for NUnit?
You can create a blank project (Choose console application for example) and in the property of the project you can select DEBUG tag and select "Start External Program". Put the path of Nunit. Then, in the start option, the command line arguments select the DLL that contains all your tests (mine is always in the nunit\bin...). Then select "enable unmanaged code debugging" and you will be able to start the project inside VS and even use the debugger step-by-step.
This is a free solution.
Now you can use Gallio: it's open source. www.gallio.org
By the way TestDriven can be downloaded for free if it's for personal use or Open Source project.
I had to find a way to use .Net Reflector inside VS few days ago and when I downloaded TestDriven it cames with. Never got any popup asking me to paid.
NUnit actually ships with a basic integrated runner. It's not very good, and not very publicized, but unless Charlie has taken it out, it should be in the source.
I know this is an old question but another way to do this is to add an external tool from the tools menu to run nunit - set the arguments to be $(TargetName)$(TargetExt) and initial directory to $(ProjectDir)\bin\Debug
check out this link
This is an old question and things have changed since the answer was accepted.
You may try NCrunch to run tests automatically or manually.
If you're running Visual Studio 2012, there is a plugin written by Charlie Poole, one of the NUnit contributers, that makes use of the new Visual Studio Unit testing plugins.
Download VsTestAdapater - it's also in the extension manager.
Unfortunately it doesn't have much grouping options yet, either by run/not run - so you can't group by class, solution and so on. It also doesn't show you any stacktrace if a test fails, just a simple green tick or red box and a message.
I haven't used it, but NUnitit is a free Visual Studio Add-in for NUnit.
http://nunitit.codeplex.com
From my experience, the best add-in for visual studio is resharper. TestDriven.Net is also good for unit tests. Hope that helps
Also found this one : http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
It is able to launch your tests in debugger, however you need to recompile the code manually each time you change something - no auto run-build integration

Resources