Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to debug with xUnit?

I'm learning xUnit and so far, have found it to be a most useful tool. It's making me rethink some of my coding tactics to TDD instead.

However, I've come across an interesting problem. My test case is failing. No real concern there, but how do I debug it?

Specifically my test case is failing due to a "out of index" error, or something similar. It's NOT failing at the assert statement. What I need now, is some way to run the test case with the Visual Studio debugger active so that I can see the status of the different variables.

I'm not going to post code, as this situation is bound to come up again. Does anyone have any idea HOW to debug the test case itself?

Almost forgot! I'm using,

  • Visual Studio 2010 Ultimate (Dreamspark license)
  • xUnit 1.9

My workflow involves using the xUnit GUI runner to run the tests.

If what I'm asking is impossible, can someone suggest an alternative test suite I could use that has what I want?

like image 269
chronodekar Avatar asked Jun 26 '12 10:06

chronodekar


People also ask

How do I debug a specific test case in Visual Studio?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug.

What is the way to debug code in test suite?

The Standard Way Go to a Chromium-based browser and open chrome://inspect . Click “Open dedicated DevTools for Node” like in the screenshot below: Put a debugger statement somewhere in your code (testing or production one). Run node --inspect-brk node_modules/.

How do I debug a test code in Visual Studio?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.


1 Answers

In VS2015 and later, install the xunit.runner.visualstudio NuGet package. Then debugging is as easy as right-clicking on the test in the test explorer window. (Test-->Windows-->TestExplorer if you can't see it). You can also right-click anywhere in the code of the test and Run Test and Debug Test will be in the context menu.

enter image description here

like image 111
bbsimonbb Avatar answered Oct 02 '22 09:10

bbsimonbb