Visual Studio Shortcut: Debug Last Unit Test

As a software developer, you are likely familiar with the process of writing code and running unit tests to ensure its functionality. This is a crucial part of the development cycle, but it can also be a source of frustration. Why? Because it often involves running the same unit test repeatedly, which can be time-consuming and tedious.

Imagine this scenario: You are deep in the zone, working on a complex piece of code. You’ve just written a unit test and you’re running it for the first time. It fails. You make some changes to your code, and run the test again. It fails once more. This cycle continues, over and over, until you’re spending more time running tests than you are writing code. It’s a common situation that many developers find themselves in, and it can be incredibly frustrating.

But what if I told you there was a way to streamline this process? A way to make running unit tests quicker and easier, freeing up more of your time for actual coding? Well, I have some good news for you!

Visual Studio, a popular integrated development environment (IDE) used by many developers, has a handy feature that can help. It’s a shortcut that allows you to debug the last run test with just one keystroke. The command is TestExplorer.DebugLastRun.

This command is a game-changer. Instead of manually navigating through your test suites and finding the last test you ran, you can now do it with a single keystroke. This not only saves you time, but it also makes the process of running unit tests less tedious and more efficient.

To make things even easier, you can customize this command with a keyboard shortcut of your choice. In my case, I’ve set it to Ctrl+D+L. This means that whenever I want to debug the last run test, all I have to do is press Ctrl+D+L on my keyboard. It’s as simple as that.

This shortcut has saved me countless hours and made the process of running unit tests much less frustrating. It’s a small change, but it can have a big impact on your productivity as a developer. So, the next time you find yourself running the same unit test over and over again, remember this shortcut. It might just save you a lot of time and hassle. Happy coding!


This blog post could not be any longer!

To contact me, send an email anytime or leave a comment below.