Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Debugging Issue with Resharper/Nunit

I am having a very frustrating problem in Visual Studio. I am using Resharper, and writing tests in Nunit.

If I set a breakpoint, it does get hit, however Step In/Over and Continue do not work, and the test never finishes. Even if I set two break points, continuing won't hit the second. If I debug a test without a breakpoint, it finishes fine.

Also, often and intermittently, when I try to debug a test by setting a break point, I can't evaluate the contents of variables, but instead see this message:

Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation.

I am using Visual Studio 2010.

Please let me know if you have any ideas of what to look at... I have scoured the web, but without any luck.

Happy to provide further information if needed.

EDIT - Example of method

Test:

[Test]
public void OneRowAddedToSourceData() {
    //Factory just returns System.Data.DataTable with correct columns.
    var sourceData = new DataTableContainerFactory().GetTargetTableContainer(DataTypeNames.EventSharedEnd);

    //GetRow just returns a populated row.
    var row = GetRow(sourceData, 123456, 123,60, 31);

    sourceData.DataTable.Rows.Add(row);
    Assert.AreEqual(1, sourceData.DataTable.Rows.Count);
}

When I set a break point on the Assert statement, and try to evaluate the data table I get this problem.

UPDATE 2! So, I have narrowed this problem down to Resharper Debugging. I changed a test class to MSTest rather than NUnit, but still got both the above problems when debugging with Resharper. However, when I ran the tests with the built in VS MSTest test runner, ALL the problems had gone!

Now I much prefer using NUnit and Resharper, so I would be very happy if someone could point me at a setting that will allow Resharper to debug properly!

like image 837
Paul Grimshaw Avatar asked Jun 01 '12 14:06

Paul Grimshaw


1 Answers

I have a possible solution, albeit with a caveat. Did some searching and ran across this blog item. It suggests turning off Enable property evaluation and other implicit function calls from Tools->Options->Debugging->General. I turned it off and I can now go into items that previously caused this problem.

The caveat is that all the properties you're used to seeing automatically evaluated are now not being shown. Instead it states Implicit function evaluation is turned off by user. All you need to do is hit the Refresh button on a property and you can see the value, but I haven't decided whether this is a trade-off I'm willing to make.

like image 68
Joel Rondeau Avatar answered Oct 18 '22 05:10

Joel Rondeau