testfx
testfx copied to clipboard
Provide additional information for assert failures
Description
Default Assert
methods should provide information in case of failures. They should at least answer the next question for a developer once a failure occurs. I've seen such behavior with CollectionAsserts
, request to review other APIs as well.
Steps to reproduce
- Create a hello world test project
- Add two
List<int>
variables.var actual = { 1, 2, 3 }
andexpected = { 1, 3, 2 }
- Add an assert.
CollectionAssert.AreEqual(expected, actual)
- Run tests
Expected behavior
A developer would immediately ask what were the elements if the collection doesn't match. Note the **additional**
information below.
Failed C.Tests.N.D
Error Message:
CollectionAssert.AreEqual failed. (Element at index 1 do not match.)
**Expected = { 2, 1, 3 }, Actual = { 1, 2, 3 }**
Stack Trace:
at C.Tests.N.D()
Actual behavior
Failed C.Tests.N.D
Error Message:
CollectionAssert.AreEqual failed. (Element at index 1 do not match.)
Stack Trace:
at C.Tests.N.D()
Environment
MSTest 1.2.0, VSTest 15.3.0, dotnet-sdk 2.0 (linux)