Latest MSTest Update Introduces WinUI Support and Enhanced Roslyn Code Analyzers with New Rules
Microsoft’s latest update to the MSTest testing framework for .NET, version 3.4, introduces several significant enhancements, including WinUI support and new features for Roslyn-based code analyzers. Released on June 5, this update aims to streamline testing processes and improve overall framework performance.
One of the standout features of MSTest 3.4 is the addition of support for WinUI framework applications. This update extends the capabilities of MSTest.Runner, making it easier to test WinUI applications, including those that are unpackaged. Microsoft has provided a sample project to help developers get started and is working on simplifying the testing process further. Additionally, performance improvements have been made by replacing Jsonite with the built-in System.Text.Json
for .NET and by implementing caching for command line options, which should enhance test execution efficiency.
The update also brings advancements to MSTest.Analyzers, which are the code analyzers for the Roslyn compiler platform included with MSTest. Nine new rules have been introduced to address common best practices and potential pitfalls. These rules focus on ensuring correct usage of assertions and attributes, enforcing design preferences, and providing other useful improvements to the testing process.
Addressing a long-standing request, MSTest 3.4 now supports STA (Single-Threaded Apartment) threads for VSTest and MSTest.Runner across all supported target frameworks. This enhancement allows specific tests or test classes to run in STA thread mode, which is essential for certain types of UI tests and other scenarios requiring a single-threaded environment. Additionally, the ability to define timeouts for fixture methods such as AssemblyInitialize
, AssemblyCleanup
, ClassCleanup
, and TestCleanup
has been introduced, offering developers more control over test execution timing.
Other notable improvements in MSTest 3.4 include the addition of [Timeout] support for all fixture methods, including initialization and cleanup methods. This feature was highly requested by users and the community. The update also enhances support for UI testing with STA threads and simplifies integration with Playwright and Aspire by reducing project boilerplate. For developers using the MSTest SDK, there’s no longer a need to explicitly include using Microsoft.VisualStudio.TestTools.UnitTesting
in files, and sample projects demonstrating SDK usage have been improved.
Overall, MSTest 3.4 represents a significant step forward in enhancing the testing capabilities and user experience for .NET developers, making it a valuable tool for modern application development and testing.