Visual studio unit testing "Start Debugging" starts all tests - visual-studio-2010

Visual studio unit testing starts all tests when I use "Start Debugging" from Debug menu, instead just ones selected in Test List editor or Test results window. It's really annoying since I use shortcut to start projects not only while testing, and number of times I just hit that key automatically and VS starts all tests instead just one or two that I am currently debugging.
Can this be changed to just run selected tests in Test List Editor ?
UPDATE : I am aware of start commands under Test menu, but problem is that that shortcut is "hardcoded" in my brain and I use it every day number of times while debugging winforms and ASP.NET projects, and in unit test case it starts all tests

Under Tools->Options, go to the Environment->Keyboard screen, then select the task you want to run when you press [F5]. Click in the "Press shortcut keys:" box (or press [Alt]+P), and then press [F5]. You'll see that it tells you that [F5] is currently used by Debug.Start. Click on the Assign button (or press [Alt]+S) to change [F5] to be what you want it to be. To restore the original functionality, repeat the above process but with Debug.Start as the item you're assigning the shortcut key to. (Or click on the Reset button if there's nothing else you want to preserve.)

There are various options to run subsets (or all) tests under the debugger (or not debugging) under the Test menu. Further options are available on the Test View and Test Results tool windows.
The tool window specific commands include running selected tests.

Related

Visual studio start line by line debugging in the middle of a program

I am working on a program and a lot of the buttons and menu items are dynamically created. Its especially hard to work on because I don't know where they are created and assigned to. It would help if I could start up the program via debugger, get to the menu, then switch to "line by line" style debugging like pressing F10, where the next line of code ran would break, and then press one of the buttons to get more info about it once the break happens. Is there any way I can do this in visual studio?
In Visual Studio, you have the Solution Explorer. There you see the Project files, they are under the top level Solution. If you right click on your main project, go to: Debug > Step Into New Instance.
If you work on a .NET application, you can use my Runtime Flow tool to see what code is executed when you select a menu item or press a button.
The closest way I could figure out how to do this is to go into Debug>Disable All Breakpoints and then when I get to where I need to be in the program go back and Enable All Breakpoints. Of course this only works if there is a large number of breakpoints in places in the program.

How to run a single test or all tests in a specific folder in Visual Studio?

So I'm moving from Visual Studio 2015 with ReSharper to Visual Studio 2017 and I'm trying to remove ReSharper from my workflow.
I know what CTRL+R,T runs either a whole TestClass or all tests depending on where you run it. It seems selecting something inside a single unit test still runs the whole test class.
Is it possible to run a single unit test?
I'm also missing right-clicking a folder in solution explorer and running all the tests in it.
Is there an extension which provides this tiny feature?
CTRL+R, T is by defualt is assign to TestExplorer.RunAllTestsInContext.
TestExplorer.RunAllTestsInContext is works as the following based on the cursor:
So it seems that TestExplorer.RunAllTestsInContext is what you are looking for...
To make sure what key may is assign to this feature click on Tools -> options -> Environment -> Keyboard, in the search bar write: TestExplorer.RunAllTestsInContext then you'll be able to see keymap/ set new one.
I'm also missing right-clicking a folder in solution explorer and running all the tests in it.
Is there an extension which provides this tiny feature?
As I know there is no such a tool basically because folders don't have any restriction on code in C#. The correct way to do such a thing is to use `TestCategory attribute.
You can run a single unit test from the Tests Explorer window. When you have done it once, you can rerun the last tests run using Ctrl+R, L. So if the last run you have done is a single unit test, it will be the only one to be rerun.
Sadly, it seems there is no shortcut to run the unit test under cursor.
Regarding the other part of your question, with the Tests Explorer window you can have tests grouped by namespace, project, class or result and then run all tests of a specific group. Maybe it can fit our needs?
Hope this help.
In the TestExplorer you can group tests by Class (there is a Group By button in the toolbar as shown in the image) then it will group tests by their classes and you can right-click on a group an click Run Selected Tests.
You can have a new filter criteria in the search box of test explorer . In the filter drop down , you can select a full name option and there you can give your namespace .
It will list entire test files located under that namespace. You can then select all of the test file and do "Run selected tests".

Is there any way to check currently executing code in visual studio?

I've been working on a C# project and I don't know the program flow. I want to know all the executing codes in a particular flow. I can press the pause button to check current executing code, but to check entire flow, I need to keep on pressing F11 or next line, which is cumbersome. BTW, I got it from here
Find out what line of code my app is currently running in Visual Studio's debug mode
I would like to know is there any way in visual studio to check currently executing code without pausing or placing break points?
I often use the VS debugging breakpoint or debug menu options like "Step Into/Out" or use the pausing button.
But if you don't want to use them, the Runtime Flow tool is a workaround I know which can help you see code that is executed:
Find out which line will be executed in Visual Studio debug mode
A feature request for VS IDE:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/17332198-is-there-any-way-to-check-currently-executing-code
In VS2017, debug has a new feature called "Run execution to here", I know that it doesn't really meet your requirement, but it is a better workaround if you don't want to step Into debugging one step by one step. Move your mouse to the icon and click the button, now your code will run and stop on that line the next time it is hit in your code path.
If you want this ability at debug time then consider IntelliTrace
ReSharper has a Call Tracking feature that can display incoming and outgoing calls sequenced in an interactive, graphical tree view.
See if this helps.
The issue here is that there is code running but you don't know where and you want to see what is going on. A good example is the code is stuck in a loop somewhere but you don't know where.
To break-into the running code:
Option 1: Select the 'Debug' menu item, and then select the 'Break All' menu item.
Option 2: Press keys Ctrl+Alt+Break.
This will break into the code where it is executing and you will step into debugging just as if you hit a breakpoint.
Happy debugging!

The option to "Administer Test Controllers" is not available on the Test menu in Visual Studio 2012

I have installed Visual Studio Ultimate 2012 RC Version 11.0.50522.1 RCREL onto Windows 8 RP on a Virtual Machine running Hyper-V on Server 2012 RC DataCenter.
All the documentation states that if you want to administer the Test Controllers in a Load test rig, you have to click on "Administer Test Controllers" in the "Test" menu. However, I don't have that option in the Test menu. I've tried adding it manually, but then it simply remains unavailable.
What am I doing wrong? This is really holding me back.
I am able to administer test controllers by creating a dummy load test and then right-Clicking on the "Controller Machine" Note and selecting "Manage Test Controllers" from there. The issue I have is that I think there might be some other menu items missing: How do you set the active Controller (I have 4 set-up). It seems to try to run the tests locally, but then the TestResults databases I have created for each of the 4 controllers aren't used, and it can't find it.
Edit:
I've submitted a bug with Microsoft at: https://connect.microsoft.com/VisualStudio/feedback/details/758768/can-not-administer-or-manage-test-controllers-from-the-test-menu
As Cybermaxs said, you can find the "Manage Test Controllers" command in the Load Test menu. However, this menu is only visible if you have a C# Web Performance and Load Test project in your solution. It doesn't help you if you only have standard C# MS Test projects.
The good new is, you can manually add the "Manage Test Controllers" option to your Test menu, which is always visible.
Workaround:
Notice that I have a Unit Test project in my solution, but no Web Performance and Load Test projects.
I have a Test menu, but no Load Test menu.
My Test Menu does not contain the Manage Test Controllers option
To manually add the command:
Right-click anywhere in that menu bar area and select "Customize".
In the Commands tab, select the Test menu bar from the drop down.
Click the Add Command button, scroll down and select the Load Test category, and what do you know... there it is. The "Manager Test Controllers" command.
Select it and click "OK" to add it to the menu. Use "Move Up" and "Move Down" to position it to you liking (personally, I prefer it just above the first break).
Click "Close" to save, and with a feeling of success, see that the prodigal command has returned :)
You can right click on a load test.
It is also available in the menu item "LOAD TEST".

Visual Studio 2010 External Tools - How to automatically attach a debugger to the tool when it is started?

I am writing a DirectShow filter, and when I want to debug it I must:
Run GraphStudio (or GraphEdit) from Tools (I added it to external tools)
Click on Debug > Attach to process...
Search for "GraphStudio" in the process list
Double click on it...
Can this be automated in VisualStudio 2010? Like, I want to select an external tool from Tools menu, and get the debugger automatically attached to it...?
This isn't perfect but it saves you a couple of steps.
In Solution Explorer, right click on your project and select properties. Now select the debugging tab. Change the Command line from $(TargetPath) to GraphStudio.exe (or whatever your process name is). Change the Attach line from No to Yes. Click on OK.
Now your steps are
Run GraphStudio from Tools
Press F5 (or Start | Debug).
The debugger will attach to the process identified by the Command line entry. If there is more than one GraphStudio running it will attach to all of them.
If you don't need to run GraphStudio as an external tool then you can simplify things even further by changing the Attach line back to No and changing the Command line to hold the full pathname of the tool you want to run. If needed you can also set working directory and Command Arguments (switches etc.)
Now just start a debugging session by pressing F5. the debugger will run Graphstudio for you and will attach to that copy only.
You can use gflags or IFEO to do this. I mention it in this answer.

Resources