BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News New MSTest SDK: Usage of MSTest Runner Extensions, Support Running Tests in Native AOT

New MSTest SDK: Usage of MSTest Runner Extensions, Support Running Tests in Native AOT

Microsoft announced the new MSTest SDK built on top of the MSBuild Project SDK system. This SDK improves the experience of testing with MSTest. There are features such as easier usage of MSTest Runner extensions, support running tests in Native AOT mode and better default suggestions. 

To get started with MSTest SDK, it is needed to create a MSTest project (or update an existing one) and replace the content of the .csproj file. It is possible to use any target framework supported by MSTest.

<Project Sdk="MSTest.Sdk/3.3.1">
  <PropertyGroup> 
      <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <!-- Additional properties and items for your tests. -->
</Project>

One advantage of the MSTest SDK is its easier usage of MSTest Runner extensions. To help a developer select the right extensions or control updates and alignments between them, Microsoft introduced a new concept of “profiles.” The new SDK provides three profiles: Default, AllMicrosoft, and None. 

Using MSTest SDK assures developers that their test project is aligned with the patterns that are provided by the main types of applications such as ASP.NET Core, Razor or Windows Desktop. It will use the default suggestions that the MSTest team makes for the test projects.

Furthermore, MSTest supports running tests in Native AOT mode. When using the MSTest SDK, it will be automatically detected if developers are publishing to AOT. All required test suites and configurations will be transparently changed to fit this specialized mode. More information about testing with Native AOT is available here

In the official announcement, a question appeared asking whether there is an easy way to support running tests both with and without native AOT. Amaury Levé, a senior software engineer at Microsoft, answered: 

Yes. MSTest SDK is the perfect fit for such a use case. By simply providing the PublishAot MSBuild property, we would change all needed references for you. So you can easily do 2 calls to the test execution command (dotnet test, dotnet exec, dotnet run or calling the exe), one with and the other without the property.

The Microsoft community also asked about support for testing WASM. Amaury Leve mentioned that there is work on the framework engine and it is in the phase of testing. There is a threat about this topic on GitHub

The MSTest SDK documentation is available on the Microsoft website. 

About the Author

Rate this Article

Adoption
Style

BT