-
-
Notifications
You must be signed in to change notification settings - Fork 111
fix: skip tests when transitive dependencies fail #4646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
Code reviewNo 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 Strengths:
The logic is sound and the implementation is correct. |
Summary
Fixes #4643 - Tests are now correctly skipped when transitive dependencies fail.
Problem
When using
DependsOnattribute with transitive dependencies:Root Cause
TestRunner.cs:81only checked if dependency state wasFailed, but when Test2 is skipped due to Test1 failing, Test3 sees Test2 inSkippedstate and proceeds to run.Solution
Changed condition from
State == TestState.FailedtoState != TestState.Passed, ensuring any non-successful dependency state (Skipped, Failed, Timeout, Cancelled) blocks execution.Changes
TUnit.Engine/Scheduling/TestRunner.cs- Updated dependency check conditionTransitiveDependenciesTeststo reproduce and validate the fixTest Plan