Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write to the Azure Devops task log from xUnit tests?

I'm running some tests in an Azure Devops pipeline and I'm seeing some failures on the build agent that I don't get locally. I'm trying some low-fi debugging and want to write some chatter out to task log but I can't see how. I've tried Console.WriteLine(), Debug.WriteLine() and Trace.WriteLine() but I don't see any of my messages in the log.

How can I write to the pipeline task log?

like image 680
Greg B Avatar asked Jul 19 '19 14:07

Greg B


People also ask

How do I write a task in Azure DevOps?

Stage: Package the extension and publish build artifacts Add "Use Node CLI for Azure DevOps (tfx-cli)" to install the tfx-cli onto your build agent. Add the "npm" task with the "install" command and target the folder with the package. json file. Add the "Bash" task to compile the TypeScript into JavaScript.

How do I create a test report in Azure DevOps?

Check test status for a test suite You can check the test status for a specific test suite. Select Test Plans to open the Test Plans page, and then select a plan to view a test suite. Select New > New test result chart to create a test results pie chart. Group by Outcome.


1 Answers

You have to use a logger that's directed at ITestOutputHelper. Details here: .net core 2.0 ConfigureLogging xunit test

If you are Ok with a third party here are two that will simplify the solution: https://blog.martincostello.com/writing-logs-to-xunit-test-output/ https://www.neovolve.com/2018/06/01/ilogger-for-xunit/

like image 162
Andrew Avatar answered Oct 19 '22 10:10

Andrew