Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

ConsoleAssert wildcard matching failures showed only raw expected/actual strings, making it difficult to identify which wildcards matched successfully and where mismatches occurred, particularly in multiline outputs.

Changes

New WildcardMatchAnalyzer class (WildcardMatchAnalyzer.cs)

  • Analyzes wildcard patterns line-by-line
  • Captures what each * or ? matched
  • Generates structured diff output

Enhanced ConsoleAssert error messages (ConsoleAssert.cs)

  • Modified AssertExpectation to detect wildcard matching context
  • Updated GetMessageText to append detailed diff for wildcard operations
  • Automatically activates for ExpectLike and ExecuteProcess methods

Before:

Expected: ("PING *(::1) 56 data bytes\n64 bytes from *")
Actual  : "PING localhost(::1) WRONG data bytes\n64 bytes from localhost"
The expected length of 45 does not match the output length of 62.

After:

Expected: ("PING *(::1) 56 data bytes\n64 bytes from *")
Actual  : "PING localhost(::1) WRONG data bytes\n64 bytes from localhost"
The expected length of 45 does not match the output length of 62.
Line-by-line comparison:
========================

Line 1: ❌
  Expected: PING *(::1) 56 data bytes
  Actual:   PING localhost(::1) WRONG data bytes
  Mismatch at position 26: expected '5' but got 'W'

Line 2: ✅
  Expected: 64 bytes from *
  Actual:   64 bytes from localhost
  Wildcard matches:
    '*' matched: localhost

Output shows:

  • Match status per line (✅/❌)
  • What each wildcard captured
  • Exact mismatch positions
  • Missing/extra lines marked with ⚠️

Backward compatible - existing tests unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve the ConsoleAssert.AssertExpectation output</issue_title>
<issue_description>Goal: Enhance the ConsoleAssert.AssertExpectation method to provide a detailed character-by-character diff when wildcard matching fails, showing exactly where wildcards matched and where mismatches occurred.
Context: The current test output only shows the full expected and actual strings, making it hard to identify where wildcard patterns (*) failed to match. This is especially problematic in multiline outputs like ping results on Linux.
Source: You have access to the full IntelliTect.TestTools.Console codebase, including ConsoleAssert.cs.

Expectations:

  • When a mismatch occurs, print:
    • Each expected/actual line pair
    • A match status (✅ or ❌)
    • A list of what each * matched in the actual string
  • If a line is present in actual but not expected, mark it as an unexpected extra line
  • If a line is present in expected but not actual, mark it as missing
  • Keep the output console-friendly (no colors or side-by-side views)
  • Add a flag or overload to enable this verbose diff mode only when needed

For example, a test like this:

        string expected = $@"*
Pinging * ?::1? with 32 bytes of data:
Reply from ::1: time*";
        string pingArgs = "-c 4 localhost";
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            pingArgs = pingArgs.Replace("-c ", "-n ");
        }
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            expected = $@"PING *(* (::1)) 56 data bytes
64 bytes from * (::1): icmp_seq=1 ttl=64 time=* ms*";
        }
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            expected = $@"PING *(*): 56 data bytes
64 bytes from *: icmp_seq=? ttl=64 time=* ms*";
        }

        ConsoleAssert.ExecuteProcess(
            expected,
            "ping", pingArgs, out string _, out _);

would currently give an output lets say like this if it failed:

Expected: ("PING *(* (::1)) 56 data bytes\n64 bytes from * (::1): icmp_seq=1 ttl=64 time=* ms*\n*--- localhost ping statistics ---*\n* packets transmitted, * received, *% packet loss, time *ms\nrtt min/avg/max/mdev = */*/*/* ms*")
Actual  : @"PING localhost (::1) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.031 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.032 ms

--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3048ms
rtt min/avg/max/mdev = 0.018/0.028/0.033/0.006 ms
"
-----------------------------------
The expected length of 212 does not match the output length of [43](https://github.com/IntelliTect/TestTools.Console/actions/runs/15918145657/job/44899524168#step:6:44)5.

Instead, we could show something that better points out exactly where the output doesn't match the expected pattern and we somehow can highlight the differences between the strings.

You have some creative freedom with how we do this, but we are constricted by the output being shown in the console.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 8, 2026 07:27
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
…mentation

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance ConsoleAssert.AssertExpectation output for better debugging Add detailed wildcard match diff to ConsoleAssert failure output Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the ConsoleAssert.AssertExpectation output

2 participants