Skip to content

[Bug]: Tests not skipped when transitive dependencies fail #4643

@epotter2297

Description

@epotter2297

Description

When using the DependsOn attribute, tests that depend on a failing test are skipped. However, they are not skipped when they have transitively dependent tests that fail.

Expected Behavior

Only Test1 should fail. Test2 and Test3 should be skipped

Actual Behavior

Test1 and Test3 fail, Test2 is skipped

Steps to Reproduce

public class Example
{
    [Test]
    public async Task Test1()
    {
        await Assert.That(true).IsEqualTo(false);
    }

    [Test, DependsOn(nameof(Test1))]
    public async Task Test2()
    {
        await Assert.That(true).IsEqualTo(false);
    }

    [Test, DependsOn(nameof(Test2))]
    public async Task Test3()
    {
        await Assert.That(true).IsEqualTo(false);
    }
}

TUnit Version

1.12.111

.NET Version

.NET 10.0

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Test3 [0:00.000] Failed: Expected to be equal to False
Expected to be equal to False
but found True

at Assert.That(true).IsEqualTo(false)
   at TUnit.Assertions.Core.Assertion`1.ThrowOrAccumulateFailure(AssertionResult result)
   at TUnit.Assertions.Core.Assertion`1.ExecuteCoreAsync()
   at TUnit.Assertions.Core.Assertion`1.AssertAsync()
   at TUnitExperiments.Sql.Tests.Example.Test3() in D:\repositories\tunitexperiments\TUnitExperiments.Sql.Tests\ProductTests.cs:line 117
   at TUnit.Core.TestMetadata`1.<>c__DisplayClass14_0.<<get_CreateExecutableTestFactory>b__2>d.MoveNext()
--- End of stack trace from previous location ---
   at TUnit.Core.ExecutableTest.InvokeTestAsync(Object instance, CancellationToken cancellationToken)
   at TUnit.Engine.TestExecutor.ExecuteTestAsync(AbstractExecutableTest executableTest, CancellationToken cancellationToken)
   at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, TestInitializer testInitializer, CancellationToken cancellationToken)
   at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, TestInitializer testInitializer, CancellationToken cancellationToken)
   at TUnit.Engine.Services.TestExecution.TestCoordinator.ExecuteTestLifecycleAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
   at TUnit.Engine.Services.TestExecution.TestCoordinator.ExecuteTestLifecycleAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
   at TUnit.Engine.Helpers.TimeoutHelper.<>c__DisplayClass1_0.<<ExecuteWithTimeoutAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at TUnit.Engine.Helpers.TimeoutHelper.ExecuteWithTimeoutAsync[T](Func`2 taskFactory, Nullable`1 timeout, CancellationToken cancellationToken, String timeoutMessage)
   at TUnit.Engine.Helpers.TimeoutHelper.ExecuteWithTimeoutAsync(Func`2 taskFactory, Nullable`1 timeout, CancellationToken cancellationToken, String timeoutMessage)
   at TUnit.Engine.Services.TestExecution.TestCoordinator.<>c__DisplayClass11_1.<<ExecuteTestInternalAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at TUnit.Engine.Services.TestExecution.RetryHelper.ExecuteWithRetry(TestContext testContext, Func`1 action)
   at TUnit.Engine.Services.TestExecution.RetryHelper.ExecuteWithRetry(TestContext testContext, Func`1 action)
   at TUnit.Engine.Services.TestExecution.TestCoordinator.ExecuteTestInternalAsync(AbstractExecutableTest test, CancellationToken cancellationToken)

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions