Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Alternative output formatting for Assert.AreEqual(string, string) #978

Open
simmotech opened this issue Sep 20, 2021 · 2 comments
Open

Comments

@simmotech
Copy link

(background: migrating a project to use MSTest.TestFramework rather than NUnit)

Output from MSTest.TestFramework:

Assert.AreEqual failed. Expected:<A A and A A>. Actual:<A, A and A, A>. 

Output from NUnit:

  Expected string length 11 but was 13. Strings differ at index 1.
  Expected: "A A and A A"
  But was:  "A, A and A, A"
  ------------^

I prefer the latter message to make it clear where the differences are - some can be quite subtle.

I was wondering whether it would be possible to add a StringAssert.AreEqual() implementation that formats its message the NUnit way. Best of both worlds then - callers choice by using StringAssert. or Assert.

@powercode
Copy link

Yeah, the MSTest variant isn't that helpful.

@nohwnd
Copy link
Member

nohwnd commented Nov 19, 2024

FWIW I would prefer rendering the whole diff in commandline even more. One problem with this is that diff is often based on coloring, and that is not working in every CI. I need to look deeper into this. I did some prototypes for the same thing here on Pester pester/Pester#2562 (comment) but that is using an existing library, which we will not be able to do here. But it could be a start to see what is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants