Releases: microsoft/testfx
v3.4.1
v3.4.0
Here are the highlights of the current release, full change log is available below:
MSTest
New and improved analyzers
We've added more code analyzers to help you prevent mistakes, and to ensure a consistent code style of your tests.
One example of a new analyzer that was added in 3.4.0 is MSTEST0024: Do not store TestContext in static members
. This analyzer has info
severity by default, and will show a message, when you store TestContext
in a static member in your class. This is not recommended, and you should be using a TestContext
property instead:
The other analyzers added in this release:
- MSTEST0017: Assertion arguments should be passed in the correct order by @Evangelink in #2256
- MSTEST0019: Prefer TestInitialize over ctor by @Evangelink in #2580
- MSTEST0020: Prefer ctors over TestInitialize methods by @Evangelink in #2582
- MSTEST0021: Prefer Dispose over TestCleanup methods by @Evangelink in #2585
- MSTEST0022: Prefer 'TestCleanup' methods over Dispose by @Evangelink in #2586
- MSTEST0023: Do not negate boolean assertions by @Evangelink in #2594
- MSTEST0024: Do not store TestContext in static members by @Evangelink in #2597
- Add PreferAssertFailOverAlwaysFalseConditionsAnalyzer by @Youssef1313 in #2799
If you've just learned about MSTest analyzers, please also check out the analyzers that were added in previous releases. They will help you ensure that your test classes and test methods are recognized by MSTest and are not accidentally ignored.
The analyzers are automatically installed with the MSTest NuGet meta-package. But can also be installed separately using the MSTest.Analyzers NuGet package.
More timeout options
Timeout can now be specified on all fixture methods, including ClassCleanup, AssemblyCleanup, TestCleanup and TestInitalize. In this case I want my [ClassCleanup]
to time out after 1 second:
Alternatively timeouts can be specified through runsettings. For example like this:
<RunSettings>
<MSTest>
<ClassCleanupTimeout>1000</ClassCleanupTimeout>
</MSTest>
</RunSettings>
Better errors on data mismatch
When you provide data that don't match your test method signature, the test will fail with an informative message, rather than just "Parameter count mismatch.".
(There is also an analyzer that helps with the same while you are writing the code.)
MSTest SDK updates
We've introduced MSTest project SDK in this .NET Blog post.
Choosing version in global.json
In this release we are promoting a way to define the MSTest.Sdk
version in global.json
. This makes it easier to specify the version in a single place, instead of in every project.
{
"msbuild-sdks": {
"MSTest.Sdk": "3.4.0"
}
}
<Project Sdk="MSTest.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
Playwright support
We've added a property to enable Playwright, to simplify creating web tests:
<Project Sdk="MSTest.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnablePlaywright>true</EnablePlaywright>
</PropertyGroup>
</Project>
Aspire testing support
Similarly we've added a property to enable Aspire testing:
<Project Sdk="MSTest.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnabledAspireTesting>true</EnabledAspireTesting>
</PropertyGroup>
</Project>
Central package management
NuGet central package management can now be used together with MSTest.Sdk
.
More examples of SDK projects
To see more examples of projects using MSTest.Sdk:
https://github.com/microsoft/testfx/tree/rel/3.4/samples/public/DemoMSTestSdk
MSTest runner
Simpler banner
We've took inspiration from MSBuild and simplified the runner banner, to show the information, on a single line:
.NET Testing Platform v1.2.0+3abae95b6 (UTC 2024/05/03) [win-x64 - .NET 8.0.4]
STA support and WinUI support
The runner can be configured to run in STA (Single Thread Apartment) mode, which is required for running UI tests. And it also supports WinUI workloads.
And more
And much more, see the complete change log here: https://github.com/microsoft/testfx/blob/main/docs/Changelog.md#3.4.0
New Contributors
A special thank you to all our new contributors:
- @mariam-abdulla made their first contribution in #2564
- @Varorbc made their first contribution in #2696
- @skanda890 made their first contribution in #2706
- @SimonCropp made their first contribution in #2714
- @Mrxx99 made their first contribution in #2717
- @dansiegel made their first contribution in #2727
- @thomhurst made their first contribution in #2749
- @Youssef1313 made their first contribution in #2799
v3.3.1
v3.3.0
v3.2.2
v3.2.1
v.3.2.0
v3.2.0-preview.24069.3
See the release notes here.
v3.2.0-preview.23623.1
See the release notes here.
v3.2.0-preview.23622.1
See the release notes here.