Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 14, 2025

When a test throws a SkipTestException, it should mark the test as skipped, but currently it's being marked as failed. This regression was introduced after version 0.25.21.

The issue occurs in the SingleTestExecutor.HandleTestFailure() method, which treated all exceptions as failures without checking for special framework exception types.

Example of the issue:

[Test]
public async Task TestA()
{
    await Task.Yield();
    throw new SkipTestException("i should be skipped");
}

Before fix: Test is marked as ❌ Failed
After fix: Test is marked as ⚠️ Skipped

Changes Made

Modified the HandleTestFailure method in SingleTestExecutor.cs to properly handle SkipTestException:

  • Added explicit check for SkipTestException before the generic failure handling
  • When caught, sets test.State = TestState.Skipped
  • Uses _resultFactory.CreateSkippedResult() with the exception's reason
  • Follows the same pattern as existing skip handling in HandleSkippedTestInternalAsync

This minimal change ensures that all three call sites of HandleTestFailure now properly handle skip exceptions:

  1. Main test execution catch block
  2. Test execution with hooks catch block
  3. After hook execution catch block

The fix maintains behavioral parity with the documentation which states that SkipTestException should result in skipped tests, not failed ones.

Fixes #2904.


✨ 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 2 commits August 14, 2025 13:17
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Throwing SkipTestException doesn't mark test as skipped anymore Fix SkipTestException handling to properly mark tests as skipped Aug 14, 2025
@Copilot Copilot AI requested a review from thomhurst August 14, 2025 13:30
Copilot finished work on behalf of thomhurst August 14, 2025 13:30
@thomhurst thomhurst marked this pull request as ready for review August 14, 2025 13:35
Copy link
Contributor

claude bot commented Aug 14, 2025

Claude finished @Copilot's task —— View job


PR Code Review

Reviewing the SkipTestException handling fix and providing comprehensive feedback.

Todo List:

  • Read repository guidelines (CLAUDE.md) - No repo guidelines found
  • Examine the core fix in SingleTestExecutor.cs
  • Review added test files for coverage and quality
  • Analyze code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Provide final recommendations

Code Review Feedback

Positive Aspects

Core Fix Quality: The fix in SingleTestExecutor.cs:398-404 is well-implemented:

  • Clean, explicit handling of SkipTestException before generic failure handling
  • Follows existing patterns (matches HandleSkippedTestInternalAsync approach)
  • Properly extracts the reason from the exception using skipEx.Reason
  • Maintains consistency across all three call sites that use HandleTestFailure

Test Coverage: Good test coverage approach:

  • Engine-level integration test validates the complete flow
  • Project-level test provides concrete example matching the issue description
  • Tests verify correct counters (0 failed, 1 not executed) confirming skip behavior

🔍 Code Quality Assessment

Implementation: The fix is minimal and surgical - exactly what's needed. The logic flow is:

  1. Check for timeout → mark as timeout
  2. Check for SkipTestException → mark as skipped
  3. Default → mark as failed

This ordering is correct and prevents the skip exception from being caught by the generic failure case.

Error Handling: Proper use of the existing result factory pattern maintains consistency with the codebase architecture.

🚫 No Significant Issues Found

Bugs: No logical errors or edge cases identified.

Performance: Zero performance impact - adds one type check in exception handling path.

Security: No security concerns - this is defensive exception handling code.

Thread Safety: Uses the same patterns as existing code, inheriting the same thread safety characteristics.

🔧 Minor Suggestions

  1. Test Naming Consistency: The test files use slightly different naming patterns:

    • SkipExceptionFixTest.cs vs SkipExceptionTests.cs
    • Consider using a consistent naming convention
  2. Test Documentation: The engine test at SkipTestExceptionTests.cs:9-20 could benefit from a comment explaining why NotExecuted.ShouldBe(1) validates the skip behavior (since skipped tests count as "not executed").

📋 Verification

The fix addresses all three call sites mentioned in the PR description:

  • Line 176: Main test execution catch block ✅
  • Line 279: Test execution with hooks catch block ✅
  • Line 294: After hook execution catch block ✅

🎯 Final Assessment

This is a high-quality, focused fix that:

Recommendation: Approve - This PR successfully fixes the regression and restores proper SkipTestException handling.


Copy link
Contributor

claude bot commented Aug 14, 2025

Claude finished @Copilot's task —— View job


PR Code Review

Reviewing the SkipTestException handling fix and providing comprehensive feedback.

Todo List:

  • Read repository guidelines (CLAUDE.md) - No repo guidelines found
  • Examine the core fix in SingleTestExecutor.cs
  • Review added test files for coverage and quality
  • Analyze code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Provide final recommendations

Code Review Feedback

Positive Aspects

Core Fix Quality: The fix in SingleTestExecutor.cs:398-404 is well-implemented:

  • Clean, explicit handling of SkipTestException before generic failure handling
  • Follows existing patterns (matches HandleSkippedTestInternalAsync approach)
  • Properly extracts the reason from the exception using skipEx.Reason
  • Maintains consistency across all three call sites that use HandleTestFailure

Test Coverage: Good test coverage approach:

  • Engine-level integration test validates the complete flow
  • Project-level test provides concrete example matching the issue description
  • Tests verify correct counters (0 failed, 1 not executed) confirming skip behavior

🔍 Code Quality Assessment

Implementation: The fix is minimal and surgical - exactly what's needed. The logic flow is:

  1. Check for timeout → mark as timeout
  2. Check for SkipTestException → mark as skipped
  3. Default → mark as failed

This ordering is correct and prevents the skip exception from being caught by the generic failure case.

Error Handling: Proper use of the existing result factory pattern maintains consistency with the codebase architecture.

🚫 No Significant Issues Found

Bugs: No logical errors or edge cases identified.

Performance: Zero performance impact - adds one type check in exception handling path.

Security: No security concerns - this is defensive exception handling code.

Thread Safety: Uses the same patterns as existing code, inheriting the same thread safety characteristics.

🔧 Minor Suggestions

  1. Test Naming Consistency: The test files use slightly different naming patterns:

    • SkipExceptionFixTest.cs vs SkipExceptionTests.cs
    • Consider using a consistent naming convention
  2. Test Documentation: The engine test at SkipTestExceptionTests.cs:9-20 could benefit from a comment explaining why NotExecuted.ShouldBe(1) validates the skip behavior (since skipped tests count as "not executed").

📋 Verification

The fix addresses all three call sites mentioned in the PR description:

  • Line 176: Main test execution catch block ✅
  • Line 279: Test execution with hooks catch block ✅
  • Line 294: After hook execution catch block ✅

🎯 Final Assessment

This is a high-quality, focused fix that:

Recommendation: Approve - This PR successfully fixes the regression and restores proper SkipTestException handling.


Copy link
Contributor

@claude [Claude Auto-Fix] Detected failed modularpipeline build (check run 48126053617).

Please analyze the build failure at https://github.com/thomhurst/TUnit/actions/runs/16976317222/job/48126053617 and commit a fix for it.

Instructions:

  1. Look at the build errors from the modularpipeline check
  2. Identify the root cause of the failure
  3. Implement and commit a fix directly to the PR branch: copilot/fix-2904
  4. Ensure the fix follows the TUnit coding standards

Focus on fixing only the build errors - do not make unrelated changes.

Copy link
Contributor

claude bot commented Aug 16, 2025

Claude finished @Copilot's task —— View job


PR Code Review

Reviewing the SkipTestException handling fix and providing comprehensive feedback.

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Examine the core fix in SingleTestExecutor.cs
  • Review added test files for coverage and quality
  • Analyze code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Provide final recommendations

Code Review Feedback

Positive Aspects

Core Fix Quality: The fix in SingleTestExecutor.cs:442-448 is well-implemented:

  • Clean, explicit handling of SkipTestException before generic failure handling
  • Follows existing patterns (matches HandleSkippedTestInternalAsync approach)
  • Properly extracts the reason from the exception using skipEx.Reason
  • Maintains consistency across all three call sites that use HandleTestFailure

Test Coverage: Good test coverage approach:

  • Engine-level integration test validates the complete flow
  • Project-level test provides concrete example matching the issue description
  • Tests verify correct counters (0 failed, 1 not executed) confirming skip behavior

🔍 Code Quality Assessment

Implementation: The fix is minimal and surgical - exactly what's needed. The logic flow is:

  1. Check for timeout → mark as timeout
  2. Check for SkipTestException → mark as skipped
  3. Default → mark as failed

This ordering is correct and prevents the skip exception from being caught by the generic failure case.

Error Handling: Proper use of the existing result factory pattern maintains consistency with the codebase architecture.

🚫 No Significant Issues Found

Bugs: No logical errors or edge cases identified.

Performance: Zero performance impact - adds one type check in exception handling path.

Security: No security concerns - this is defensive exception handling code.

Thread Safety: Uses the same patterns as existing code, inheriting the same thread safety characteristics.

🔧 Minor Suggestions

  1. Test Naming Consistency: The test files use slightly different naming patterns:

    • SkipExceptionFixTest.cs vs SkipExceptionTests.cs
    • Consider using a consistent naming convention
  2. Test Documentation: The engine test at SkipTestExceptionTests.cs:9-20 could benefit from a comment explaining why NotExecuted.ShouldBe(1) validates the skip behavior (since skipped tests count as "not executed").

📋 Verification

The fix addresses all three call sites mentioned in the PR description:

  • Line 176: Main test execution catch block ✅
  • Line 323: Test execution with hooks catch block ✅
  • Line 338: After hook execution catch block ✅

🎯 Final Assessment

This is a high-quality, focused fix that:

Recommendation: Approve - This PR successfully fixes the regression and restores proper SkipTestException handling.


@thomhurst
Copy link
Owner

@claude [Claude Auto-Fix] Detected failed modularpipeline build (check run 48205300630).

Please analyze the build failure at https://github.com/thomhurst/TUnit/actions/runs/17001967683/job/48205300630 and commit a fix for it.

Instructions:

  1. Look at the build errors from the modularpipeline check
  2. Identify the root cause of the failure
  3. Implement and commit a fix directly to the PR branch: copilot/fix-2904
  4. Ensure the fix follows the TUnit coding standards

Focus on fixing only the build errors - do not make unrelated changes.

This was referenced Aug 21, 2025
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.

Throwing SkipTestException doesn't mark test as skipped anymore
2 participants