Skip to content

[Bug]: Test time tracking is inconsistent #4711

@epotter2297

Description

@epotter2297

Description

[Before] hooks are not counted towards the total test time, but [After] hooks are

Expected Behavior

The total time for A should be either ~300ms or ~100ms

Actual Behavior

The total time for A is ~200ms

Steps to Reproduce

public class Example
{
    [Test]
    public async Task A()
    {
        await Task.Delay(100);
        await Assert.That(true).IsEqualTo(true);
    }
}

public static class ExampleHooks
{
    [BeforeEvery(Test)]
    public static async Task Setup(CancellationToken token)
    {
        await Task.Delay(100, token);
    }

    [AfterEvery(Test)]
    public static async Task Finish(CancellationToken token)
    {
        await Task.Delay(100, token);
    }
}

TUnit Version

1.13.11

.NET Version

.NET 10.0

Operating System

Windows

IDE / Test Runner

Visual Studio

Error Output / Stack Trace

Additional Context

I'm not 100% sure whether including the hooks in the test time makes sense or not, since I could see the argument of "It's 'before' or 'after' the test and therefore not part of it". But it should at least be consistent, and it probably makes more sense to include them if they count towards the timeout period.

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