Skip to content

Conversation

@thomhurst
Copy link
Owner

Summary

Fixes #4643 - Tests are now correctly skipped when transitive dependencies fail.

Problem

When using DependsOn attribute with transitive dependencies:

  • Test1 fails
  • Test2 depends on Test1 → correctly skipped
  • Test3 depends on Test2 → incorrectly runs and fails (should be skipped)

Root Cause

TestRunner.cs:81 only checked if dependency state was Failed, but when Test2 is skipped due to Test1 failing, Test3 sees Test2 in Skipped state and proceeds to run.

Solution

Changed condition from State == TestState.Failed to State != TestState.Passed, ensuring any non-successful dependency state (Skipped, Failed, Timeout, Cancelled) blocks execution.

Changes

  • Fix: TUnit.Engine/Scheduling/TestRunner.cs - Updated dependency check condition
  • Tests: Added TransitiveDependenciesTests to reproduce and validate the fix

Test Plan

  • New tests pass - Test3 is now correctly skipped
  • All existing DependsOn tests still pass
  • 304/310 engine tests pass (2 unrelated F#/VB failures)

Fixes #4643

When Test3 depends on Test2, which depends on Test1, and Test1 fails:
- Test2 is correctly skipped (direct dependency)
- Test3 was incorrectly running instead of being skipped

Changed TestRunner to skip tests when dependencies have any non-Passed
state (Failed, Skipped, Timeout, Cancelled), not just Failed state.
This ensures transitive dependencies are properly handled.

Changes:
- Updated TestRunner.cs condition from `State == TestState.Failed` to `State != TestState.Passed`
- Added TransitiveDependenciesTests to reproduce and verify the fix
@claude
Copy link
Contributor

claude bot commented Feb 2, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Review Summary:

This PR provides a clean and focused fix for transitive dependency handling. The change from State == TestState.Failed to State != TestState.Passed correctly handles all non-successful states (Skipped, Failed, Timeout, Cancelled), ensuring tests are skipped when any upstream dependency doesn't pass.

Strengths:

  • Minimal, surgical fix that addresses the root cause
  • Proper test coverage with both unit and integration tests
  • Follows established testing patterns in the codebase
  • Compliant with all CLAUDE.md requirements (dual-mode, performance, AOT compatibility)
  • Uses modern C# features appropriately

The logic is sound and the implementation is correct.

@thomhurst thomhurst enabled auto-merge (squash) February 2, 2026 23:04
@thomhurst thomhurst merged commit 3c94b16 into main Feb 2, 2026
12 of 13 checks passed
@thomhurst thomhurst deleted the fix/transitive-dependency-skipping branch February 2, 2026 23:26
This was referenced Feb 3, 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.

[Bug]: Tests not skipped when transitive dependencies fail

2 participants