Skip to content

[MTP] No output from TestContext.Progress #1336

@cbersch

Description

@cbersch

Using Microsoft.Testing.Platform I don't get any output from TestContext.Progress.

Consider the example

using System.Runtime.CompilerServices;
using NUnit.Framework;

public sealed class LoggingTests
{
    [OneTimeSetUp]
    public Task OneTimeSetUpAsync() => LogAsync();

    [SetUp]
    public Task SetUpAsync() => LogAsync();

    [Test]
    public Task TestMethodAsync() => LogAsync();

    private static async Task LogAsync([CallerMemberName] string memberName = "")
    {
        await TestContext.Progress.WriteLineAsync($"{DateTimeOffset.UtcNow} | TestContext.Progress called from: {memberName}");
        await Task.Delay(TimeSpan.FromSeconds(2));
        await TestContext.Out.WriteLineAsync($"{DateTimeOffset.UtcNow} | TestContext.Out called from: {memberName}");
        await Task.Delay(TimeSpan.FromSeconds(2));
    }
}

with csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>true</ImplicitUsings>

    <EnableNUnitRunner>true</EnableNUnitRunner>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" Version="4.4.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
  </ItemGroup>
</Project>

and global.json

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

When running this with MTP and detailed output:

dotnet test --project .\MyProject.csproj --output detailed

I don't get any progress messages:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateMTPMicrosoft Test Platform related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions