Skip to content

Conversation

@dennisdoomen
Copy link
Member

@dennisdoomen dennisdoomen commented Sep 21, 2025

Given the following test:

[Fact]
public void Will_include_the_full_comparands_for_long_text()
{
    var subject = """
    The streets were quiet except for the faint hum of neon signs flickering in the night. A cat darted across the alley, chasing shadows only it could see. Somewhere, a radio whispered a half-forgotten song, mixing with the distant rumble of a train. The air carried the scent of rain on warm asphalt, heavy and restless. Each step felt like moving between moments—time stretching, folding, and twisting—while the city itself seemed to wait, holding its breath for what might come next.
    """;

    var expected = """
    The streets were quiet except for the faint hum of neon signs flicering in the night. A cat darted across the alley, chasing shadows only it could see. Somewhere, a radio whispered a half-forgotten song, mixing with the distant rumble of a train. The air carried the scent of rain on warm asphalt, heavy and restless. Each step felt like moving between moments—time stretching, folding, and twisting—while the city itself seemed to wait, holding its breath for what might come next.
    """;

    // Act
    subject.Should().Be(expected);
}

Before this PR, the result would be

Expected subject to be the same string, but they differ at index 66:
                   ↓ (actual)
  "…neon signs flickering in…"
  "…neon signs flicering in…"
                   ↑ (expected).

With the line length extended to 80 and the full subject and expectation included when it was truncated, this will be reported now

Expected subject to be a match with the expectation, but it differs at index 66:
                   ↓ (actual)
  "…neon signs flickering in the night. A cat darted across the alley, chasing shadows…"
  "…neon signs flicering in the night. A cat darted across the alley, chasing shadows…"
                   ↑ (expected)

Full expectation:

    "The streets were quiet except for the faint hum of neon signs flicering in the night. A cat darted across the alley, chasing shadows only it could see. Somewhere, a radio whispered a half-forgotten song, mixing with the distant rumble of a train. The air carried the scent of rain on warm asphalt, heavy and restless. Each step felt like moving between moments—time stretching, folding, and twisting—while the city itself seemed to wait, holding its breath for what might come next.",

Full subject:

    "The streets were quiet except for the faint hum of neon signs flickering in the night. A cat darted across the alley, chasing shadows only it could see. Somewhere, a radio whispered a half-forgotten song, mixing with the distant rumble of a train. The air carried the scent of rain on warm asphalt, heavy and restless. Each step felt like moving between moments—time stretching, folding, and twisting—while the city itself seemed to wait, holding its breath for what might come next."

Note If BeEquivalentTo runs a string comparison, we will not include the full comparands, unless the new option IncludingFullStringsInDifference is used.

#3088

@github-actions
Copy link

github-actions bot commented Sep 21, 2025

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@dennisdoomen dennisdoomen force-pushed the improve-string-comparison branch 2 times, most recently from f53f48a to 575cff3 Compare September 23, 2025 17:51
@dennisdoomen dennisdoomen changed the title Improve reporting of string differences Improve reporting of the differences between long strings Sep 23, 2025
@dennisdoomen dennisdoomen force-pushed the improve-string-comparison branch 8 times, most recently from f99d1a8 to 269576e Compare September 27, 2025 11:38
@dennisdoomen dennisdoomen marked this pull request as ready for review September 27, 2025 11:38
@dennisdoomen dennisdoomen requested a review from jnyrup September 27, 2025 11:38
@dennisdoomen dennisdoomen added this to the 8.8 milestone Sep 27, 2025
@coveralls
Copy link

coveralls commented Sep 27, 2025

Pull Request Test Coverage Report for Build 18198614323

Details

  • 93 of 93 (100.0%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 97.159%

Totals Coverage Status
Change from base Build 18189677942: 0.008%
Covered Lines: 12820
Relevant Lines: 13039

💛 - Coveralls

@dennisdoomen dennisdoomen force-pushed the improve-string-comparison branch from 269576e to 4ee71a7 Compare September 28, 2025 06:28
@dennisdoomen dennisdoomen force-pushed the improve-string-comparison branch from 4ee71a7 to 67716ad Compare October 2, 2025 16:02
@dennisdoomen dennisdoomen force-pushed the improve-string-comparison branch from 67716ad to b63ff16 Compare October 2, 2025 16:03
This was referenced Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants