You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using string1.Should().Be(string2), if the strings differ it can be awkward to work out where the difference is for large string. E.g. if you're checking that building some json/xml/whatever-long-text works correctly.
Click for example test output for xml text
Expected xmlString1 to be
"<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Greatest Hits</TITLE>
<ARTIST>Dolly Parton</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>RCA</COMPANY>
<PRICE>19.90</PRICE>
<YEAR>1982</YEAR>
</CD>
<CD>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary Moore</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin records</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
</CATALOG>" with a length of 756, but
"<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Greatest Hits</TITLE>
<ARTIST>Dolly Parton</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>RCA</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1982</YEAR>
</CD>
<CD>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary Moore</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin records</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
</CATALOG>" has a length of 755.
At the moment, I'm copy & pasting from the test output into a diff tool so I can find where the difference is.
It would be great if the assert message also included a hint to where to the first difference.
Some ideas that I'd find handy (any of these could go after or before the current message showing the full actual vs expected text)
For multi-line strings, include the line number of the first difference
Include a snippet of the string, that shows a few characters before & after the index of the first difference (say 14 characters before the difference, and 6 characters after)
A unified diff style display of the two strings (like git would show)
The specific details of how to show what the differences are (or at least the first difference) aren't very important, anything that helps speed up tracking down the differences would be 👍
The text was updated successfully, but these errors were encountered:
When using
string1.Should().Be(string2)
, if the strings differ it can be awkward to work out where the difference is for large string. E.g. if you're checking that building some json/xml/whatever-long-text works correctly.Click for example test output for xml text
At the moment, I'm copy & pasting from the test output into a diff tool so I can find where the difference is.
It would be great if the assert message also included a hint to where to the first difference.
Some ideas that I'd find handy (any of these could go after or before the current message showing the full actual vs expected text)
The specific details of how to show what the differences are (or at least the first difference) aren't very important, anything that helps speed up tracking down the differences would be 👍
The text was updated successfully, but these errors were encountered: