Skip to content

Testing Platform overwriting/removing user console output #4425

Description

@thomhurst

Using TUnit, I created this simple test suite:

public class Tests
{
    [Before(TestSession)]
    public static async Task BeforeTestSession()
    {
        Console.WriteLine($"BeforeTestSession started at {DateTime.Now}");
        await Task.Delay(TimeSpan.FromSeconds(5));
        Console.WriteLine($"BeforeTestSession ended at {DateTime.Now}");
    }
    
    [Before(Assembly)]
    public static async Task BeforeAssembly()
    {
        Console.WriteLine($"BeforeAssembly started at {DateTime.Now}");
        await Task.Delay(TimeSpan.FromSeconds(5));
        Console.WriteLine($"BeforeAssembly ended at {DateTime.Now}");
    }
    
    [Test]
    public void Test1()
    {
        Console.WriteLine($"Executing Test at {DateTime.Now}");
    }
}

If you just do a dotnet run on the CLI, you'll have to be quick, but when it starts to show "BeforeAssembly started", you'll see it render really quickly, but then it'll be removed and overwritten by the rendering of the [✓0/x0/↓0] ConsoleApp5.dll (net9.0|x64).

I guess this is related to the new interactive output and showing running tests etc. But overwriting user output means they may lose visibility of important information.

Metadata

Metadata

Assignees

Labels

area/mtpMicrosoft.Testing.Platform core library.area/terminal-reporterConsole / terminal test reporter.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions