Stepping through and debugging code in Unit tests

前端 未结 8 2001
离开以前
离开以前 2020-12-09 01:34

I have not been able to debug or step through unit test.

Here is my sample test code...

using System;
using System.Text;
using System.Collections.Gen         


        
相关标签:
8条回答
  • 2020-12-09 02:06

    Another solution...

    You need to run and attach the debugger

    Set this line at the first line executed in your test (maybe in the test class constructor)

    System.Diagnostics.Debugger.Launch();
    

    then when debug window open , chose the visual stdio

    0 讨论(0)
  • 2020-12-09 02:08

    Two simple steps to debug a unit test in Visual Studio 1. Set a break point in the unit test that you want to debug 2. Right click anywhere within the unit test and select "Debug Tests" from the context menu

    Stepping thru the unit test is very similar to how we step thru any other code in visual studio. Step Over - F10 Step Into - F11 Step Out = Shift + F11

    You can also debug the unit test from the test explorer window 1. First locate the unit test that you want to debug 2. Double clicking on a unit test will open that unit test 3. Set a break point in the unit test 4. In the test explorer, right click on that unit test and select "Debug selected tests from the context menu"

    To debug all the tests Click Test - Debug - All Tests The execution will then pause at all the break points in all the unit tests

    One thing to keep in mind is that, the break points with in the unit tests will be ignored, if you select run tests instead of debug tests in visual studio.

    0 讨论(0)
提交回复
热议问题