Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

OverrideResult(TestState.Skipped, "reason") ignores the provided reason and displays "Skipped" instead.

[Test]
public async Task TestSkip()
{
    TestContext.Current!.Execution.OverrideResult(TestState.Skipped, "test-skip foo bar baz.");
}
// Output: "Skipped" ❌
// Expected: "test-skip foo bar baz." ✅

Changes

  • TestCoordinator.cs: When reporting skipped tests, check OverrideReason from overridden results before falling back to "Skipped"

The skip reason resolution order is now: SkipReasonOverrideReason (if overridden) → "Skipped"

Original prompt

This section details on the original issue you should resolve

<issue_title>OverrideResult does not reflect the specified reason even when Skipped is set</issue_title>
<issue_description>I used OverrideResult to dynamically skip tests based on certain conditions.
The test was skipped as expected, but the reason was not reflected and just shows "Skipped".

Environment:

  • .NET 10.0.100
  • TUnit 1.5.6

Code:

[Test]
public async Task TestSkip()
{
    TestContext.Current!.Execution.OverrideResult(TestState.Skipped, "test-skip foo bar baz.");
}

Console:

Image

Visual Studio 2026 Test Explorer:

Image

(Sorry for the message of images in Japanese)</issue_description>

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

@thomhurst Thanks I'll take a look.

As a work around, you should be able to use the static method Skip.Test(reason)</comment_new>
<comment_new>@thomhurst
Docs will be updated 😄
https://github.com/thomhurst/TUnit/pull/4018/files</comment_new>


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

When OverrideResult is called with TestState.Skipped and a reason,
the reason was not being reflected in test output. The code was only
checking test.Context.SkipReason but not the OverrideReason from the
overridden result.

Updated TestCoordinator to check OverrideReason when the result is
overridden to Skipped.

Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix OverrideResult to reflect specified reason when skipped Fix OverrideResult skip reason not being displayed Jan 8, 2026
Copilot AI requested a review from thomhurst January 8, 2026 12:54
@thomhurst thomhurst marked this pull request as ready for review January 8, 2026 14:07
Copilot AI review requested due to automatic review settings January 8, 2026 14:07
@thomhurst thomhurst merged commit 2cebb17 into main Jan 8, 2026
11 of 13 checks passed
@thomhurst thomhurst deleted the copilot/fix-overrideresult-reason branch January 8, 2026 14:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where calling OverrideResult(TestState.Skipped, "reason") would ignore the provided reason and display "Skipped" instead of the custom message. The fix adds logic to check the OverrideReason property when reporting skipped tests, falling back to the default "Skipped" message only if no override reason is available.

Key Changes:

  • Modified skip reason resolution logic to prioritize SkipReasonOverrideReason (if overridden) → default "Skipped" message
Comments suppressed due to low confidence (1)

TUnit.Engine/Services/TestExecution/TestCoordinator.cs:307

        foreach (var dependency in test.Dependencies)
        {
            if (collected.Add(dependency.Test.Context.Metadata.TestDetails))
            {
                CollectAllDependencies(dependency.Test, collected, visited);
            }
        }

This was referenced Jan 12, 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.

OverrideResult does not reflect the specified reason even when Skipped is set

2 participants