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.

“Inconclusive” error in ReSharper unit test runner caused by “async void”

The ReSharper unit test runner doesn’t like test methods which are declared as “async void”.

Unfortunately you won’t get any compiler or intellisense warning to tell you. When trying to run the test in ResSharper unit test runner it will first get a blue question-mark icon and when you run it individually it will get the test result Inconclusive.

Example of an “conclusive” test result and a good one.

Code:

[TestMethod]
public async void This_Test_Will_Cause_Inconclusive_Message()
{
    // tests
}

[TestMethod]
public async Task This_Test_Will_Run_Ok()
{
 // tests
}