MSTest -> Why Can't I Debug Using BreakPoints? - visual-studio

I setup breakpoints, then run "Run Tests" in Visual Studio. Why don't MSTest run to my breakpoints?

Choose Debug -> Tests In Current Context (or otherwise)

For Visual Studio 2012 Express, I chose:
TEST -> Debug -> All Tests

When using MSTest via Start external program "mstest" specify the /noisolation option.

I had this problem after upgrading to MSTest V2. I referenced the new nuget packages, removed the existing MSTest reference, but no debugging. I read that I should no longer be using a test settings file, so I removed that; no joy. I finally discovered that clearing out my temp dir did the trick.

In my case it was that I had selected Release build. When I switched to Debug then my breakpoint was hit.

Visual Studio 2022
with msTest, options:
When you are in test method press Ctrl + r, Ctrl + t to debug the current test method.
Go to menu test > debug last run
Go to menu Test > debug all test
Go to menu Test > Test Explorer, when the window test explorer open, right clic over the test method you want > Debug
the problem is that you "run" the test, but you must "debug" the test so you can make use of break points.
cheers.
Reference about Testing in visual studio

Related

Why does VS claim that my project is of DLL type when it is set as an EXE type?

I am trying to launch the Console.Tests part of https://github.com/ServiceStack/ServiceStack.Redis in Debug mode (by pressing F5), so that I can place a breakpoint in it.
Visual Studio (2013), however, refuses to do so, claiming that my project is of DLL type:
Why? What am I missing?
BTW, building this project produces Console.Tests.exe in Visual Studio 2013\Projects\ServiceStack.Redis-master\tests\Console.Tests\bin\Debug which runs just fine.
Also, if I attempt to debug the project by right-clicking its menu, it also starts just fine:
Why? What am I missing?
You need to tell Visual Studio which StartUp project it should run by right clicking on Console.Tests project in solution explorer and selecting Set as Startup Project.

How to debug single Nunit test visual studio 2013

How can I debug a specific Nunit test from visual studio? I have multiple TestFixtures in different files. Whenever I run a test it always hits other TestFixture's debug point/exception.
Install nunit test adapter and you can right click inside a unit test method and click debug tests. You can also use the Test Explorer window.

is it possible to debug my solution while debugging a test?

I've got VS2010, nunit, and resharper. I've written a bunch of tests and when I debug those tests I can set breakpoints within the test code itself and those are hit, but no breakpoints within my solution itself are hit (the actual code that the test code is calling).
Is there a way to hit the breakpoints throughout my solution while debugging a test?
Have you tried Tools->Options->Debugging->Enable Just My Code
This may happen sometimes if you have build errors and debugger is executing binaries from previous build (Launch old version). This option can be disabled in Visual Studio:
Tools -> Options -> Projects and Solutions -> Build And Run
On Run, when build or deployment errors occur
The message box is not displayed and the newly built version of the
application is not started. This option is set when you select Do not
show this dialog again in the message box, and then click Yes.

Debugging code that's being tested in Visual Studio 2010

I am having some problems with a given test, that I'd like to debug the code that is being tested, while the test runs.
Is this possible?
If yes, how can I just debug this one test? I can only see options for running or the whole solution, or the whole set of tests in the current context or all impacted tests. I'd like to just run this one test, if possible!
I'm running Visual Studio 2010.
Put a breakpoint in the test and run the test with debug - use the test explorer to select just that test and "run selected".
See this MSDN page (How to: Run Automated Tests from Microsoft Visual Studio).

How to debug mbunit/Gallio unit tests in visual studio

I am trying to figure out how I can hit breakpoints in my unit tests that are written with MbUnit/Gallio. I tried running Gallio.Icarus, attaching vs debugger to it, the breakpoints weren't hit.
Next I tried to start Gallio.Echo from project properties, but I was getting an error message, after supplying the dll, saying only .exe's can be tested.
The unit test runs fine from Gallio.Icarus, however, I am unable to debug them.
Thanks!
Grab Gallio v3.0.6 Update 1. Load up your tests and click on the shiny new "Debug" button in the Icarus GUI itself.
I would use TestDriven.Net for this. It supports MbUnit tests, and you can debug by simply right clicking from within Visual Studio
A much better answer is found here:
gallio test runner plugin to visual studio 2010
The answer is to add the following section to your *.csproj file the after the <ProjectGuid> section section:
<ProjectTypeGuids>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB}
; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
See Also:
How Does Visual Studio Identiy test projects?
A list of supported VS2010 project types
Second list of GuIDs for supported project types

Resources