microsoft / microsoft/testfx

Testing Platform overwriting/removing user console output

Open
#4,425 6 comments 2 reactions 1 assignee View on GitHub

@nohwnd is already working on this.

Since Jan 15, 2025.

area/mtp area/terminal-reporter
Dominant language
C#
Stars
1k
Forks
312
Avg merge
7h 46m
Merged PRs (30d)
465

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.