【问题标题】:Printing the Console output in the Azure DevOps Test Run task在 Azure DevOps 测试运行任务中打印控制台输出
【发布时间】:2021-07-28 00:43:43
【问题描述】:

我正在使用 [BeforeTestRun] 钩子为我的 specflow 测试做一些初始的一次性设置。这确实会检查某些用户以确保它们是否存在,如果它们不存在,则使用特定的角色和权限创建它们,以便自动化测试可以使用它们。执行此操作的函数会在Console.Writeline 上打印很多有用的信息。 当我在本地系统上运行测试时,我可以在主功能文件上看到这个钩子函数的输出,以及每个场景下每个场景的输出。但是当我通过 Azure DevOps 管道运行测试时,我不确定在哪里可以找到 [BeforeTestRun] 的输出,因为它没有绑定特定的测试场景。 Run Tests Tasks 的控制台没有这方面的信息。

有人可以帮我在某处显示此输出,以便我采取相应措施。

我尝试使用 System.Diagnostics.Debug.PrintSystem.Diagnostics.Debug.PrintSystem.Diagnostics.Debug.WriteLineSystem.Diagnostics.Trace.WriteLine,但在管道控制台上似乎没有任何效果。

[BeforeTestRun]
public static void BeforeRun()
{
    Console.WriteLine(
        "Before Test run analyzing the users and their needed properties for performing automation run");
}

我希望我的输出在某处可见,以便在需要时根据该信息采取行动。

【问题讨论】:

标签: azure-devops azure-pipelines


【解决方案1】:

控制台日志是不可能的。

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

(来源:https://developercommunity.visualstudio.com/content/problem/631082/printing-the-console-output-in-the-azure-devops-te.html

但是,还有另一种方法:

您的构建将包含一个文件扩展名为 .trx 的附件。这是一个 xml 文件,包含每个测试的 Output 元素(另请参阅 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-19
    • 2021-04-28
    • 2020-05-24
    • 2023-02-26
    • 2011-02-23
    • 2020-12-22
    • 1970-01-01
    相关资源
    最近更新 更多