Resharper running all tests when only a single one is selected
Asked Answered
D

5

7

I'm using Resharper 4.5 with Visual Studio 2008 and MBUnit testing, and there seems to be something odd with using ReSharpher to run the tests.

On the side there are the icons beside the class each test method with the options Run and Debug. When I select Run it just shows me the results of the single test. However I noticed that the test was taking a considerably long time to run.

When I ran Sql Server profiler and start stepping through the code, I realized that its not just running the selected test, but every single one in the class. Is there any reason it makes it look like its only running one unit test while actually running them all?

Its getting to be a pain waiting for all integration tests to run when I only care about the reuslt of one, is there any way to change this?

Dissimulation answered 10/7, 2009 at 16:15 Comment(4)
Do you use Gallio to run MBUnit tests?Tasse
Which version of Gallio are you using? Older versions contained a bug that produced behavior similar to what you are describing>Rubescent
I have Gallio installed, but I don't think I use it to run the tests. I just use the MBUnit exe. How do I tell if VS is using Gallio? The version installed is 3.0.0.179.Dissimulation
Same issue, very annoyingMcsweeney
B
5

I just encountered this today and I think I might have realized what causes this bug, I had my methods named similarly

    [TestMethod]
    public void TestSomething()

    [TestMethod]
    public void TestSomethingPart2()

I saw that running TestSomething() would run both, however running TestSomethingPart2() would not. I concluded if you name methods that an exact match can occur for the method name it will run the test. After renaming my second test to TestPart2Something this issue went away.

Beastings answered 4/1, 2010 at 17:50 Comment(3)
That is quite interesting. Has anyone else confirmed this issue?Fucoid
I've noticed this behaviour even though my method names are entirely different!Adjudicate
Whoever downvoted a point in time answer about specific versions of technology 7 years after the question was asked... you're just sillyBeastings
S
5

I can confirm that this is a problem with ReSharper 5.1.

To reproduce run test A from my sample code below (all tests will execute); run test AB (all except A will execute); etc:

[TestMethod]
public void A()
{
    Console.WriteLine("A");
}

[TestMethod]
public void AB()
{
    Console.WriteLine("AB");
}

[TestMethod]
public void ABC()
{
    Console.WriteLine("ABC");
}

[TestMethod]
public void ABCD()
{
    Console.WriteLine("ABCD");
}

[TestMethod]
public void ABCDE()
{
    Console.WriteLine("ABCDE");
}

It took me ages to work this out. I had the remote debugger attached to a development server, and it was breaking a bit more often than I was expecting it to...

It seems to be doing a StartsWith instead of a Contains as others have said. The workaround is to not have test method names that start with the name of another test method name.

Spindrift answered 7/10, 2010 at 23:18 Comment(0)
M
3

I hope this shows up under Chris post.

I had a similar situation that confirms the behavior he noticed.

[TestMethod()]
public void ArchiveAccountTest()

[TestMethod()]
public void ArchiveAccountTestRestore()

So running the first method would execute both and running the second would not. Renamed my second method to TestRestore and the problem went away.

Note: I'm using Resharper 5.1 so it's still a problem.

Mackenie answered 27/7, 2010 at 20:24 Comment(0)
J
0

When you right-click in the editor, the context menu appears from which you can run and debug tests. Right-click inside a test method to run or debug that single test. Right-click outside of any test method to run or debug the entire test class contained in the current file.

Jumper answered 10/7, 2009 at 16:22 Comment(3)
So the icon beside the method declaration that says "(Method Name) Run" really means "Run entire class"? That seems very misleading...Dissimulation
I didn't write it, so I can't really say. Did the right-click context menu work?Jumper
No, its still running them all, even when I right click and say Run Unit Tests.Dissimulation
J
0

The current release of Gallio includes a Unit Test runner with MbUnit (and NUnit) support built-in.

From the Resharper menu, you have the option of running a Single unit test or all Tests in your solution. What is cool, is that the Keyboard-shortcuts for this are:

  • Alt + R, U, R - Run test from current context (if you are at a [Test] level, it runs one test, if you are at a [TestFixture] level, it runs all in the fixture!)
  • Alt + R, U, N - Runs all Unit Tests in your Solution

I highly recommend that you uninstall your current Gallio and then check C:\Program Files\Jetbrains\Resharper\plugins\bin and clear out and files there. Then install Gallio afresh.

Once you've done this, you should startup VS2008 and goto at the Resharper | Plugins menu to check that the Gallio plugin is active. This will give you support for MbUnit.

Jarrodjarrow answered 5/12, 2009 at 12:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.