Microsoft adds WinUI support to MSTest

By Paul Krill

Microsoft has updated its MSTest testing framework for .NET, enhancing it with WinUI support and best practices for Roslyn-based code analyzers.

The company announced MSTest 3.4 on June 5. The MSTest framework can be accessed via NuGet.

With MSTest 3.4, support for WinUI framework applications is added to MSTest.Runner. With this improvement, a project sample is offered and work is under way to simplify testing of unpackaged WinUI applications. Microsoft also has improved the test runner’s performance by using built-in System.Text.Json for .NET rather than Jsonite and by caching command line options.

For MSTest.Analyzers, a set of code analyzers for the Roslyn compiler platform that ships with MSTest, Microsoft has added nine rules to cover common best practices and pitfalls. The rules are intended to ensure correct use of assertions and attributes, help enforce design preferences, and offer other improvements.

Also in MSTest 3.4, Microsoft has fixed a longstanding request to support STA threads in MSTest for VSTest and MSTest.Runner for all supported target frameworks. Plans call for improving the experience by having some specific tests or test classes run in STA thread mode. Microsoft also has introduced the ability to define timeouts on fixture methods, such as AssemblyInitiative, AssemblyCleanup, ClassCleanup, and TestCleanup. This provides more control over test execution.

Microsoft also has added [Timeout] support to all fixture methods in MSTest 3.4, including initialize and cleanup methods. Also added was STA thread support for UI tests. Both were issues reported by users and the community. Testing with Playwright and Aspire has been simplified by removing project boilerplate. And for the MSTest SDK, developers no longer need to explicitly add using Microsoft VisualStudio.TestTools.UnitTesting in files. Plus, sample projects illustrating how to use the SDK have been enhanced.

© Info World