Visual Studio 2022 v17.2 Introduces Live Unit Testing — Visual Studio Magazine

News

Visual Studio 2022 v17.2 preview live unit tests

The second preview of Visual Studio 2022 version 17.2 has been released with a full range of tweaks across the board: including C++, .NET productivity, web tools, and testing.

Regarding this last element, Microsoft’s documentation indicates that the release plans significant improvements to live unit testing.

Live Unit Testing automatically runs unit tests in the background and reports results and code coverage in real time. When code is changed, it provides feedback on the impact of the changes on existing tests and whether the new code is covered by existing tests, reminding developers to write unit tests when fixing bugs or adding new features. 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 enhancements in Preview 2 include:

  • Support for more out-of-the-box solutions than before
  • Better management of large solutions
  • Better default behavior with large test sets
  • Better capabilities for undoing in-progress tests
  • More configuration options with new Live Unit Testing wizard and Lutignore file

“We’re also previewing a more advanced test progress bar that includes more details about where Test Explorer is in the test execution process with live updates,” Microsoft says.

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

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

Live unit testing in Preview 2 was deemed so important that Microsoft devoted an entire blog post to it. “You can see at a glance what your code coverage is for each line of your product code,” he says. “You get instant in-editor feedback with pass/fail icons in the margin and you can easily run or debug impacted tests from Live Unit Testing icons. Live Unit Testing will help you detect if new changes in code cause tests to fail when you develop so you don’t forget to test before pushing changes again.”

For debugging and diagnostics, a new change is that the IEnumerable viewer can explore larger collections objects in the tabular/datagrid 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 viewer
[Click on image for larger view.] The IEnumerable viewer (source: Microsoft).

A new feature for web tools integrates the creation of new Azure Function projects into the general New Project dialog, allowing developers to choose and configure Azure Function triggers without the need for another dialog. “You also have the option to create a dockerfile as part of the project creation. When additional configuration through Connected Services is needed, the experience guides you there and through the rest of the steps.”

There are also a series of improvements for .NET productivity, with Microsoft reports:

  • We now introduce embedded source and source link as part of Go to Implementation if a referenced assembly has an embedded source or source link. This lets you navigate to the original source files that implement the target symbol.
  • In .NET 7, we added a new attribute called StringSyntaxAttribute that will let you tell us what type of data a string represents, such as JSON, Regex, or DateTime.
  • We’ve added support for this attribute so you 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 indicate that a colon is expected.
  • We now have a refactoring that wraps a collection of initializers for Visual Basic and C#.
  • We now support built-in languages ​​for the new C# 11 language with raw string literals. To use raw string literals, set the language version in your project file to preview: preview.
  • Background code analysis now has more configuration options in Tools > Options allowing you to set the diagnostic scope to None to disable background code analysis.
  • Code cleanup now supports all code style options.

Microsoft Teams dev tools have received just as many changes, with other improvements to Git tools, Razor editor, container tools, and more. Everything is detailed in the release notes.

About the Author


David Ramel is an editor and writer for Converge360.



Comments are closed.