简体   繁体   中英

After opening in Visual Studio 2015 unit test debugger steps in to wrong function

I have an nUnit test and I upgraded the project from VS 2012 to 2015. Now when debugging the unit test the debugger steps in to the wrong function. The tests still pass, but debugging isn't working.

When I get to getAString = newClass.ReturnString() the debugger steps in to both .ReturnString and .ReturnInt, then when I get to Dim getAnInt = newClass.ReturnInt() it doesn't step in to it at all. And neither returns a value. Why does it run both functions when I call the first one? There's obviously no parallelism in the code below. When I debug in nUnit it steps in to the correct functions and they both return a value, when I debug in Resharper or Nunit Test Adapter the debugger doesn't work.

Imports NUnit.Framework

<TestFixture()>
Public Class Class1

<Test()>
Public Sub Test_Across_DateRanges()


    Dim newClass As New MyNewClass

    Dim getAnInt = newClass.ReturnInt()

    Dim getAString = newClass.ReturnString()

    Assert.That(getAnInt = 5)
    Assert.That(getAString = "Why is this breakpoint being hit?")

End Sub

End Class



Public Class MyNewClass
    Public Function ReturnInt() As Integer
        Return 5
    End Function
    Public Function ReturnString() As String
        Return "Why is this breakpoint being hit?"
    End Function

End Class

There are a few root causes to my symptoms, and a few fixes.

Right click solution in Solution Explorer > Properties > make sure eeeeeverything is set to Debug / Any CPU. Select Configuration Properties and the top line will become active. Select Debug, Any CPU, then open Configuration Manager and double check there! And also set Debug / Any CPU in Project contexts. And most of the things here: Visual Studio 2015 RTM - Debugging not working Make sure to File > Save As... on the .sln and vbproj files.

I'm pretty sure it was the build to Any CPU.

There are other things to check:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM