Notes about Live Unit Testing in Visual Studio

MS introduced Live Unit Testing in the Enterprise edition of Visual Studio 2017.

I quite like it. A few notes about some issues I had:

  • Don’t mix testing frameworks (MsTest, NUnit, xUnit). Live testing will use one or another test adapter, but only one at the same time. Depending on which one is active you will have tests excluded from live-testing.
  • Update your references. If you cannot debug your unit-tests anymore with Live Unit Testing enabled, have a look at this support case. You might need to delete your existing project reference to “Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll” and install the NuGet packages MSTest.TestAdapter and MSTest.TestFramework instead.
  • Choose your tests wisely. You might want to exclude your long-running integration tests and other tests from being executed by Live Unit Testing: Right-Click on your test project, go into that “Live Unit Testing” entry and include and exclude what you need to be covered by Live Testing.
  • Included test files not updated automatically. If you have included test-data files in your project that are copied to your Output Directory by the build process: These are not updated automatically. I had to Stop and Start Live Testing in order to access added or updated files.

Hope you find that helpful.

Breakpoint in ASP.NET MVC View not hit when using RazorGenerator

If your breakpoints in an ASP.NET MVC view are not hit: Check if you are using RazorGenerator for this particular view:

Screenshot of ASP.NET MVC view Properties. Custom tool set to RazorGenerator
RazorGenerator enabled for ASP.NET MVC view

Fix: Temporarily disable Razor Generator removing the “RazorGenerator” text from the Custom Tool property. Make sure to put it back in after your debugging session.