I've fixed a null reference problem. Now when I run the test related to that class, it fails. I'd like to know whether is possible to run a test in debug mode so I'll know why I am getting the exception?
The test was written by some else, it's calling a method, as part of the setup, with a lot of logic in it. I'd like to step in to see how values are being returned.
Thank for helping.
It is indeed possible, using the NUnit Test Adapter for Visual Studio 2012.
Also, just so you're aware: failed assertions will throw exceptions, causing the debugger to break execution. You can adjust your configuration to work around this, as described in this thread:
Debugging in VS2012 with NUnit without throwing exceptions?
You can also use ReSharper, which makes it pretty easy. Or, you can just go into the properties for your DLL project that has the test in it and make the test runner you are using the exe that runs when you run the project.
Right click the project in the solution explorer, select "Properties" from the menu, go to the "Debug" tab, click the "Start external program" radio button then set the project as the active project and run in debug mode.
Related
I've used Visual Studio 2017 to create a queue triggered Azure Function. All that the default generated code does is write a message to the log. The code works, but if you set a breakpoint on it, it is ignored by the debugger.
I have same problem with another queue triggered function that has more complex code, but I created this one as a very simple test case.
What do you have to do to get debug breakpoints to work on this type of project?
Answer was found here which is:
(1) right click your project and go to properties page
(2) select "Build" on left
(3) click "Advanced..." button
(4) change "Debugging information" to "Full"
As stupid as it sounds, I managed to make it work by unchecking the option
Automatically close the console when debugging stops
in Tools > Options > Debugging > General
When a test hangs in a loop, the small green progress bar in the test runner does not proceed, but there is no way to stop the test run. Or is there?
VS 2013
Edit: This occured when using the XUnit TestRunner. The Cancel button simply did not show up. After testing various test runners in a new solution, it turned out, that it works with all of them. Finally it also worked with my original solution. So there was some anomaly in the state of my VS environment that caused cancel to disapper.
You can click "Cancel" in Test Explorer:
Show Test Explorer by going to TEST > Windows > Test Explorer.
This is in Visual Studio 2013.
Instructions for other versions of VS can be found here
Sorry for waking up an old thread:)
just wanted to share my solution here, I had the same issue on VS 2015.
There is some text below the search input just where the cancel should appear (take a look at #Codeman print screen), the text is actually some description on how you can setup a build for your tests, the text is several lines and at the end you have "do not show this any more" just press it and then the cancel button appears:)
Very strange bug, sorry I do not have some print screens of this
hope it helps someone
VS2015. If the hanging tests are executables instead of DLLs you need to kill those tests in the task manager. You need to close the Test Explorer Window to prevent automatic running. While the tests are running/hanging you will not be able to compile the according project.
For me the solution was to go to Task Manager, locate chromedriver and end the task.
Visual Studio 2022 Professional version 17.2.3.
I have found the solution to this issue. To stop the run after cancel is pressed, just set the 'Terminate process on cancel' option to True.
I'm using boost::test with Visual Studio 2010, in a Win32 console project. boost::test appears to take care of the main() function, by providing its own. It looks like I don't have to provide a main().
Thing is, I want my console output not to disappear immediately, but this means that I'd have to define the main() function somehow, to get it to stay on screen. Thing is any attempts I make to redefine main() appear to get ignored.
I know that Cppunit can output test results during compilation - does boost::test have anything like this?
I use this configuration: In one solution I have a main project and a test project; the main project depends on the test project; the test project has a post-build event with $(TargetPath) which runs the test project and redirects the output to the output-window. Test errors can be located by double-clicking on the corresponding line in the output window.
Ctrl+F5 - start without debugging. This will keep the output window open.
You might try out Gallio in combination with the Boost test adapter for Gallio from Alexander Tsvyashchenko. The interesting part is that you will benefit all the goodies of Gallio (test output, filtering, reports, and integration with many 3th party tools such as CC.Net, NAnt, etc.)
Here is described how to setup your project to get what you want.
I am trying to run my unit tests (Test->Debug->Tests in current solution) in VS 2010.
The solution is built in Release mode. When I try to do that, VS is crashing.
Do you have any ideas?
Cheers
I guess the problem lies with the test code. Test code is crashing and bringing down the VS IDE too.
See while debugging, the tests are run in-proc and therefore because of any exception in test code the VS would crash too.
I would suggest that you set the "Break on Common language runtime exceptions" (Goto Debug -> Exceptions menu), and then debug the tests. That way you could hunt the exception in your test code.
I've just started using resharper and I found a very annoying thing about it. When debugging a unit test, I try to step-into (F11) a method, but visual studio complains that source code is not available. The problem is that resharper is wrapping method calls with its own classes. Of course I can put a braeakpoint further in my source, but this is very annoying. Do you know if thereĀ“s a solution for this? By the way, I'm using NUnit to write my tests
Thanks
Federico
After some playing around I managed to recreate this on my setup (Xunit.net in resharper, visual studio 2008)... The steps I took to recreate this are:
Set the dll that contains the tests as the startup project (I know you don't need to do this, was just trying to get it to fail)
Put a breakpoint in the unit test
Push F11 (the shortcut key for 'step into' in my configuration)
This complains 'Cannot start test project 'RowanBeach.Crm.Domain.Test' because the project does not contain any tests.'
Run the 'Debug Unit Tests' command from the Resharper menu (I have this bound to a key combination on my machine)
This displays the 'No source code available...' message
Of course that's not how you should start unit tests from resharper! :) If that's what you were doing (or something similar), try this instead:
Don't bother setting the dll as the startup project - it doesn't need to be
build or rebuild the dll that contains the tests
set the breakpoint
Put the cursor somewhere in the source code for the unit test you want to debug to set it as the 'current context' unit test
Run the 'Debug Unit Tests' command from the Resharper menu (You might want to bind this to a key combination if you haven't already)
Hopefully, that should work
What type of tests are you running - NUnit? MS Test? Something else?
I've never found it difficult to debug tests using R# - just put a breakpoint in your test and go. What method are you trying to step into? I've generally not tried to step into the NUnit methods themselves (assertions etc) but stepping into your own code should be okay.
If you can come up with a quick example, I'd be happy to try it myself.