Test tools for .NET and cross-platform apps

KendraHavens

There are a few new goodies added to your everyday test tools that I hope will improve your test inner loop! To familiarize yourself with these new features you can see them in action in the Visual Studio Tips and Tricks video on Testing or keep reading!

Show in Test Explorer

Easily jump from the editor to the test in the Test Explorer with the new Show in Test Explorer command (Ctrl+E,S). Show in Test Explorer is also available from the editor right-click menu, CodeLens test glyph, and the right-click in the Solution Explorer.

Image of the show in test explorer command in Visual Studio
Show in Test Explorer command in right-click menu

Play a sound when a test run completes!

The Test Explorer can now play a sound when a test run completes. You can select two sounds, one that indicates the test run succeeded with all passing tests and a second sound to indicate the test run completed with at least one failing test. These sounds are completely customizable using the Windows sound dialog!

Image of test audio cues in visual studio test explorer
Test Audio Cues in Test Explorer settings

Console.WriteLine in Test Explorer

Console.Writeline will now appear in the test detail pane. For xUnit, output that uses the ITestOutputHelper will appear. Standard output as well as standard error will be shown in this pane, so your test output is available where you need it.

Image of console writeline output appearing in test explorer in visual studio
Console.Writeline output appears in Test Explorer details

Remote Testing

Run and debug tests on Linux containers, WSL, or over SSH connections!

Visual Studio can make your cross-platform development easier than ever with remote testing! You can now run Linux tests from Visual Studio by connecting the Test Explorer to remote environments. These can be Linux containers, WSL, and even SSH connections! Check out the setup documentation to get started at https://aka.ms/remotetesting.

Normally I’d have to push to a CI run before getting feedback from Linux test or other operating systems, but now I can get it all in my inner dev loop, including debugging a test in a Linux container.

Image of remote testing in visual studio debugging a test in a Linux container
Debug a test in a Linux container with Remote Testing

Test web apps with Playwright

Playwright is the latest in cross-platform, asynchronous web UI testing. It’s built with modern browsers and services in mind meaning each step automatically uses awaits. This reduces the flakiness that typically plagues web UI tests. Not only is Playwright cross-platform, but it is also cross-language supporting TypeScript, JavaScript, Python, Java, and .NET. It also comes with a recorder that generates tests based on your actions. Read more https://playwright.dev.

Image of playwright recorder generating .NET test code
Playwright recorder generating .NET tests

Where can I learn more?

If you are interested in more on performance, how hot reload can apply to the Test Explorer, or more on running tests over SSH connections check out the longer demo from .NET Conf.

You can find more test tools documentation at http://aka.ms/visualstudiotest.

To get started with Remote Testing follow the instructions at https://aka.ms/remotetesting.

As always, we are incredibly thankful to the community who suggested many of these features, commented design suggestions, and upvoted them to the top of our backlog! This guidance is invaluable to creating tools that the community loves. Share what you’d like to see next in your test experience in the comments!

Thanking you all and wishing you well,

11 comments

Comments are closed. Login to edit/delete your existing comments

  • Shimmy Weitzhandler

    To me, as long as horizontal scroll (Shift+scroll) isn’t supported on VS, and especially in test explorer, it’s still considered broken.

  • Swati Sharma

    My focus is on the programming side rather than real testing, so I am not a testing expert. However, while dealing with.Net, I favour xUnit.net over NUnit for unit testing.

  • Jonathan Lane

    Are there any plans to make an extension similar to Test Explorer for Visual Studio Code? The current extensions for C# tests pale in comparison to the Visual Studio offering.

    • KendraHavensMicrosoft employee

      There aren’t any plans that I’m involved in. Though I do think some new abilities arrived with the new VSCode Test APIs that test adapters for each language can take advantage of.

  • James Lonero

    One function that would be useful is to add a button to the test explorer that would reset all of the tests to “Not run” Therefore, I could start with a new slate of all of the tests and when running only the tests I need, I will easily be able to know which passed and which didn’t without looking through all that had run previously. I was hoping for something like this function in VS2019, but it has not come. Hopefully in VS2022.

  • Christian Andritzky

    The “Show in Test Explorer” command is definitely a welcome (and long needed) addition.

    But it’s still not enough to handle huge solutions with thousands or tens of thousands of tests.
    This is the main reason why we still cannot phase out third party tools (namely: ReSharper) and solely work with VS built in features.
    From my point of view there are two feature missing:
    1. Working with unit test “sessions” that contain only a (small) subset of all available tests. Or maybe extend the playlist feature.
    2. Have an (interactive) icon on the gutter for running/debugging tests and showing the last run state in addition to the code lens glyph. Please note that people turn off code lens in large solutions for performance reasons.

    And of course – as always – improve performance and responsiveness for large solutions 😉

  • Ken Varn

    I am still rather disappointed that Microsoft has removed the TCM tool that was formerly used to import Test Cases into Azure Devops. This tool made it really easy to import large quantity of tests methods into Azure Devops Test Cases rather than have to individually import each Test Method. Please bring this tool back or create an equivalent tool that can batch import.

  • James Wright

    I’m really stuck in my school project using the windows form .net in C#, everything works fine until I get to the end and add the web browser from the toolbox, it all looks good but every time I click the play button it tells me the browser can’t play the video. I’m working with the new 2022 version and even the version that is on azure labs has a very similar problem. Any ideas on what the fix may be? The main error I get is that the browser needs updating, yet no way to do so within the program?