Visual Studio 2022 v17.2 Previews Live Unit Testing

The second preview of Visual Studio 2022 version 17.2 is out with a full gamut of tweaks across all areas: including C++, .NET productivity, web tools and testing.

Regarding the latter item, Microsoft documentation says the release is previewing significant improvements to Live Unit Testing.

Live Unit Testing automatically runs unit tests in the background and reports the results and code coverage in real time. When code is changed, it provides feedback on how changes impacted existing tests and whether the new code is covered by any existing tests, reminding developers to write unit tests as they fix bugs or add new features. It works with C# and Visual Basic projects that target .NET Core or .NET Framework in the Enterprise edition of Visual Studio.

Live Unit Testing in Animated Action
[Click on image for larger, animated GIF view.] Live Unit Testing in Animated Action (source: Microsoft).

Live Unit Testing improvements in Preview 2 include:

  • Supporting more solutions out-of-the-box than before
  • Better handling of large solutions
  • Better default behavior working with large test sets
  • Better cancellation abilities of test runs in progress
  • More configuration options with new Live Unit Testing wizard and Lutignore file

"We are also previewing a more advanced test progress bar that includes more details on where the Test Explorer is in the test execution process with live updates," Microsoft says.

As with all preview features, a flag needs to be set to access the functionality: Tools > Options > Environment > Preview Features.

Live Unit Testing Preview
[Click on image for larger view.] Live Unit Testing Preview (source: Microsoft).

Live Unit Testing in Preview 2 was deemed so important that Microsoft devoted and entire blog post to it. "You can see what your code coverage is for each line of your product code at a glance," it says. "You get instant feedback in the editor with pass/fail icons in the margin and you can easily run or debug the impacted tests from the Live Unit Testing icons. Live Unit Testing will help you catch if new code changes cause tests to fail as you develop so you won't forget to do a test run before pushing changes ever again."

For debugging and diagnostics, one new change is that IEnumerable visualizer can explore larger collections objects in the tabular/data grid view in a more streamlined way. Also, "It supports IEnumerable collections where T can be simple types or complex types like dictionaries, encapsulated."

The IEnumerable Visualizer
[Click on image for larger view.] The IEnumerable Visualizer (source: Microsoft).

A new feature for web tools is integrating the creation of new Azure Function projects into the general New Project dialog, which lets developers pick and configure Azure Function triggers without the need for another dialog. "You also get the option to create a dockerfile as part of the project creation. When further configuration through Connected Services is needed, the experience navigates you there and guides you through the rest of the steps."

There is also a raft of improvements for .NET productivity, with Microsoft reporting:

  • We now surface embedded source and Source Link as part of Go to Implementation if a referenced assembly has embedded source or Source Link. This allows you to navigate to the original source files that implement the target symbol.
  • In .NET 7 we added a new attribute called the StringSyntaxAttribute which will allow you to tell us what kind of data a string represents such as JSON, Regex, or DateTime.
  • We added support for this attribute so you will get syntax highlighting for the new StringSyntaxAttribute for JSON.
  • We added a diagnostic message for the new JSON StringSyntaxAttribute when there is a misplaced string literal in an object literal to say that a colon is expected.
  • We now have a refactoring that wraps a collection of initializers for both Visual Basic and C#.
  • We now support embedded languages for the new C# 11 language feature raw string literals. To use raw string literals, set the language version in your project file to preview: <LangVersion>preview</LangVersion>.
  • Background Code Analysis now has more configuration options in Tools > Options allowing you to set the diagnostic scope to None in order to turn off Background Code Analysis.
  • Code Cleanup now supports all code style options.

Microsoft Teams development tools received just as many tweaks, with other improvements being made to Git tooling, the Razor editor, container tools and more. It's all detailed in the release notes.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


Subscribe on YouTube