-
Notifications
You must be signed in to change notification settings - Fork 297
Releases: microsoft/testfx
v4.2.3
35d2383 Assets 2
v4.2.2
3ee14aa Assets 2
v4.2.1
02621de Assets 2
v4.1.0
26fb0d3 Assets 2
v4.0.2
88c9fc5 Assets 2
v3.11.1
cb5afc3 Assets 2
v4.0.1
2eb19d5 Assets 2
v4.0.0
What is new?
Assert.That
MSTest v4 adds a new type of assertion, that allows you to write any expression, and it will inspect the result to give you more information on failure. Providing a very flexible way to assert complicated expressions. Here a simple example:
[TestClass] public sealed class Test1 { [TestMethod] public void TestMethod1() { var animal = "Tiger"; var zoo = new Zoo(); Assert.That(() => zoo.GetAnimal() == animal); } } public class Zoo { public string GetAnimal() { return "Giraffe"; } }
Assert.That(() => zoo.GetAnimal() == animal) failed.
Details:
animal = "Tiger"
zoo.GetAnimal() = "Giraffe"
CallerArgumentExpression
CallerArgumentExpression is consumed by all assertions, to make them aware of the expressions used in the assertion. In the example below, we now know what both the expected and actual values are. But also what value they come from, giving us opportunity to provide better error messages:
[TestClass] public sealed class Test1 { [TestMethod] public void TestMethod1() { string animal = null; Assert.AreEqual("Giraffe", animal); } }
Error Message: Assert.AreEqual failed. Expected:<Giraffe>. Actual:<>.
'expected' expression: '"Giraffe"', 'actual' expression: 'animal'.
Breaking changes
We hidden many types that should have never been public in the first place. We believe that most of the changes won't have any real user impact. For the changes where we expect user impact migration guide from v3 is provided: https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-migration-v3-v4
See the MSTest changelog here: https://github.com/microsoft/testfx/blob/main/docs/Changelog.md#4.0.0
See the Microsoft.Testing.Platform changelog here: https://github.com/microsoft/testfx/blob/main/docs/Changelog-Platform.md#2.0.0
Full changelog here: v3.11.0...v4.0.0
Assets 2
v3.11.0
e64ddb3 Assets 2
v3.10.5
8c73bdb