I just started working on a new project with a ton of existing code, and the tests are not passing. I’m more of an Nunit guy, so I’m not immediately familiar with the failure points of Xunit.
the problem is in code that sort of looks like this:
fooStringProperty = readSomeFile;
//later
fooStringProperty.ShouldBe(expectedContents)
the above code fails with an error that looks like this:
error : Position: First difference is at position 0
Expected: contentsOfFooStringProperty
Actual:
contentsOfFooStringProperty
basically, it’s somehow getting this newline in there, and I have no idea how. I have a ton of these failures all over the code base, and it works for other people, so I’m wondering if it’s some xunit version issue?
edit: this is totally a CRLF issue between mac and windows. problem resolved 🙂
It seems unlikely that xUnit is injecting newlines. It seems more likely that you really have got rogue newlines, for some completely other reason.
I would suggest that you diagnose this by debugging through the code and checking the values in the debugger. Set a breakpoint on the assertion line, and see whether it looks right to you. Assuming it really is broken at that point, put a breakpoint where you’re fetching/reading/computing each value. Basically apply the normal steps to working out unexpected behaviour – ignore the xUnit aspect.