Azure DevOps:缺少绿色测试的控制台输出 [英] Azure DevOps: Console output for green tests is missing

查看:14
本文介绍了Azure DevOps:缺少绿色测试的控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将 NUnit 测试执行从 TeamCity 迁移到 Azure DevOps.迄今为止最大的问题之一 - 无法看到绿色(通过)测试的控制台输出.DevOps 中是否真的缺少这个基本功能,或者我根本不知道去哪里找?

We migrated our NUnit tests execution from TeamCity to Azure DevOps. One of the biggest issues so far - there is no way to see Console output for green (passed) tests. Is this basic feature really missing in DevOps, or I simply do not know where to look?

以下是查看失败测试的控制台输出的方法:

Here is how to view Console output for failed tests:

更新:在文档中有一个提示"(https://docs.microsoft.com/en-us/azure/devops/pipelines/test/review-continuous-test-results-after-build?view=azure-devops):

UPDATE: In the documentation there is a "Tip" (https://docs.microsoft.com/en-us/azure/devops/pipelines/test/review-continuous-test-results-after-build?view=azure-devops):

如果使用 Visual Studio 测试任务运行测试,诊断输出从测试中记录(使用 Console.WriteLine、Trace.WriteLine 或TestContext.WriteLine 方法),将作为附件出现测试失败.

If you use the Visual Studio Test task to run tests, diagnostic output logged from tests (using any of Console.WriteLine, Trace.WriteLine or TestContext.WriteLine methods), will appear as an attachment for a failed test.

文本明确指出测试失败".看起来确实没有办法(没有简单的方法)看到非失败测试的控制台输出,这很令人沮丧.

Text explicitly states "for a failed test". Looks like there is indeed no way (no easy way) to see Console output for non-failed tests, which is very discoureging.

推荐答案

Azure DevOps 不显示已通过测试的控制台输出:

Azure DevOps does not show Console output for passed tests:

该产品目前不支持打印控制台日志以通过测试,我们目前没有计划在不久的将来支持此功能.

The product currently does not support printing console logs for passing tests and we do not currently have plans to support this in the near future.


他们建议将控制台输出写入文件并将文件作为测试附件上传:


They recommend writing the Console output to a file and uploading the file as a test attachment:

但是,要实现您想要的目标,您几乎走在正确的道路上.将必要的信息写入文件并作为测试附件上传是正确的方法.您可以使用此 API 附加文件,它会在 azure devops 中作为测试用例级别的附件自动上传:https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.testcontext.addresultfile?view=mstest-net-1.2.0

However, to achieve what you want, you are almost in the right path. Writing the necessary info to a file and uploading as test attachment is the right approach. You can use this API to attach the file and it will be automatically uploaded as test case level attachment in azure devops : https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.testcontext.addresultfile?view=mstest-net-1.2.0


(两个引号的来源:https://developercommunity.visualstudio.com/content/problem/631082/printing-the-console-output-in-the-azure-devops-te.html)

还有另一种获得成功测试输出的方法:

There's another way to get the output for successful test:

您的构建将包含一个文件扩展名为 .trx 的附件.这是一个 XML 文件,包含每个测试的 Output 元素(另请参见 https://stackoverflow.com/a/55452011):

Your build will have an attachment with the file extension .trx. This is a XML file and contains an Output element for each test (see also https://stackoverflow.com/a/55452011):

<TestRun id="[omitted]" name="[omitted] 2020-01-10 17:59:35" runUser="[omitted]" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Times creation="2020-01-10T17:59:35.8919298+01:00" queuing="2020-01-10T17:59:35.8919298+01:00" start="2020-01-10T17:59:26.5626373+01:00" finish="2020-01-10T17:59:35.9209479+01:00" />
  <Results>
    <UnitTestResult testName="TestMethod1">
      <Output>
        <StdOut>Test</StdOut>
      </Output>
    </UnitTestResult>
  </Results>
</TestRun>

这篇关于Azure DevOps:缺少绿色测试的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆