nunit / nunit/nunit

Improve error message when comparing strings

Open
#2,935 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

is:enhancement
Dominant language
C#
Stars
2.6k
Forks
766
Avg merge
1d 3h
Merged PRs (30d)
24

Description

[Test]
public void Test()
{
    Assert.AreEqual(" ", "\u00A0"); // space and no breaking space
}

Results in:

  String lengths are both 1. Strings differ at index 0.
  Expected: " "
  But was:  " "
  -----------^

Which looks confusing as they look the same.

Preferable would be:

  String lengths are both 1. Strings differ at index 0.
  Expected: " "
  But was:  "\u00A0"
  -----------^

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the NUnit string-comparison failure formatting used by the Assert.AreEqual example. Reproduce the space versus non-breaking-space case, then add coverage for the expected escaped output and verify that the failure message distinguishes the characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.