question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestContext.Progress shows up as Warning in TFS/Azure Dev Ops

See original GitHub issue

Version information

Issue

TestContext.Progress written during a test shows up in TFS/Azure DevOps as warning when running a test via a VSTest task with NUnit Adapter 4.3.1.0. ConsoleOut is enabled via runsettings.

Code used to write progress in test: TestContext.Progress.WriteLine("Message via TestContext.Progress"); Expected result white (informational) log line in TFS. Instead the message is shows as a warning (orange) warning in TFS:

ProgressMessageAsWarningInTFS

Possible cause

My theory regarding the cause of the issue based on analysis of the code (did not run/debug the code): The text written via TestContext.Progress.WriteLine results in a TestOutput event in EventListenerTextWriter:

private bool TrySendToListener(string text) { context.Listener.TestOutput(new TestOutput(text, _streamName, context.CurrentTest?.Id, context.CurrentTest?.FullName));

The TestOutput event is in handled in nunit3-vs-testadapter in class NUnitEventListener OnTestEvent:

public void OnTestEvent(string report) { . . . case NUnitTestEventHeader.EventType.TestOutput: TestOutput(new NUnitTestEventTestOutput(node)); break;

The handled TestOutput is always forwarded as warning in NUnitEventListener TestOutput:

public void TestOutput(INUnitTestEventTestOutput outputNodeEvent) { . . . recorder.SendMessage(TestMessageLevel.Warning, text); }

Possible solution: recorder.SendMessage(outputNodeEvent.IsProgressStream ? TestMessageLevel.Informational : TestMessageLevel.Warning, text); or recorder.SendMessage(outputNodeEvent.IsErrorStream ? TestMessageLevel.Warning : TestMessageLevel.Informational, text); Further more one could argue that if settings.ConsoleOut == 1 the message level should also be TestMessageLevel.Informational, similar to the message sent in NUnitEventListener TestFinished.

Apologies if the issue turns out to be caused by something else entirely (e.g. configuration on my side).

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mharwigcommented, Feb 24, 2023

@OsirisTerje Hi, Thanks for the update.

I just updated to Version 4.4.0-beta.1 in the reproducer, and it works as intended.

Run with version 4.3.1: https://martinharwig.visualstudio.com/NUnitVsTestAdapterBug/_build/results?buildId=14&view=results image

Run with Version 4.4.0-beta.1 (no more warning with progress message): https://martinharwig.visualstudio.com/NUnitVsTestAdapterBug/_build/results?buildId=15&view=results

1reaction
mharwigcommented, Dec 5, 2022

@OsirisTerje I realize that those settings are not related to the adapter. However using customBatchSizes has the side effect that TFS runs the tests via the translation layer (see comment here: https://github.com/microsoft/azure-pipelines-tasks/issues/10709#issuecomment-508416719), as opposed to calling vstest.console.exe directly. Apparently the variant ran via the api handles the warning messages differently. I will see if I can find the time to create a reproducer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Review test results - Azure Pipelines
Review continuous test results with a build or release pipeline in Azure Pipelines or Team Foundation Server (TFS)
Read more >
Different number of warnings reported from VSTS build
I'm building a project hosted on VSTS on a local build server. On the builds main page I have "Build process succeeded 0...
Read more >
Azure Pipelines - Visual Studio Test does not publish ...
We are using Azure DevOps to run a build that runs tests using Visual Studio Test. Everything is working fine, Console.
Read more >
Adapter V4 Release Notes
Net Framework tests fails when .Net 8 is present on system. 1037 TestContext.Progress shows up as Warning in TFS/Azure Dev Ops. Thanks to...
Read more >
Automating Selenium Tests in Azure Pipelines
In this lab, you will learn how to execute selenium test cases on a C# web application, as part of the Azure DevOps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found