I am using xUnit with Visual Studio Test Explorer and when there's an error in Assert.Equal()
, I am getting a truncated version of Actual and Expected.
For example,
Xunit.Sdk.EqualException
Assert.Equal() Failure
Expected: List<Result>
[Result {
Status = StatusEnumValue1,
Message = "The request or response type contains a special ty"...,
Path = "1234" }]
Actual: WhereListIterator<Result>
[Result {
Status = StatusEnumValue1,
Message = "The request or response type contains a special ty"...,
Path = "1234" }]
This test fails because the Message
s are different, but given that the Message
s are truncated, I cannot see the part where they actually are different from the Test Explorer. Even when I copy it out, it's still truncated.
Is this a known shortcoming of xUnit? I can keep debugging the test or use WriteLine
to compare the Message
s but I am surprised the xUnit framework does not have a way to allow full response to be shown. I also tried the Resharper test explorer, and that does not solve the problem.
It turns out this is an xUnit issue.
ovation22 points own below the exact location of the code that controls this hard limit on number of characters.
I have bypassed this issue by using FluentAssertions library instead. The error from xUnit used with FluentAssertions does not truncate any error message.