【问题标题】:How to use external files for vstest in Azure Pipelines如何在 Azure Pipelines 中使用外部文件进行 vstest
【发布时间】:2019-08-06 15:16:21
【问题描述】:

我正在尝试在 Azure Pipeline 中启动一个单元测试,该测试会打开一个外部文件 (myReport.rdl)。目标是检查传递给 LocalReport 类的数据集是否与报表定义一致。 不幸的是,我收到以下错误:

"d:\a\1\s\TestResults\Deploy_VssAdministrator 2019-08-04 06_29_01\Out\Reports\myReport.rdl".

如何将 .rdl 文件复制到正确的位置?有没有其他解决办法?

代码

      var localReport = new LocalReport(); // Microsoft.Reporting.WinForms
      localReport.ReportPath = ReportPath; // Reports/myReport.rdl 
      ... 
      localReport.Render("PDF", DeviceInfo, out _, out _, out _, out _, out var warnings);

【问题讨论】:

  • 总是发布你的代码。没有代码的错误可能意味着一百万种不同的事情。
  • mstest?单位? xunit.net?
  • 您是否在测试或.runsettings 中指定了DeploymentItem 属性?

标签: azure azure-pipelines vstest


【解决方案1】:

根据您在问题中提到的错误。我猜你正在使用属性 [DeploymentItem(string filePath, string outputDirectory)]。测试任务总是将deploymentItem filePath中指定的文件复制到这个目录“../Out/outputDirectory(你指定的输出目录)/file”。

例如: [DeploymentItem(@"MyData/myReport.rdl", "Reports")].
myReport.rdl 将被复制到“d:\a\1\s\TestResults\Deploy_**********\Out\Reports\myReport.rdl”。 要在您的测试方法中使用 myReport.rdl,您需要指向您的 ReportPath = @"Reports \myReport.rdl"。

如果您不指定 outputDirectory,如下例所示: [DeploymentItem(@”MyData/myReport.rdl”)].
myReport.rdl 将被复制到 d:\a\1\s\TestResults\Deploy_**********\Out\myReport.rdl"。 要在您的测试方法中使用 myReport.rdl,您可以将 ReportPath = "myReport.rdl" 指向。

有关更多信息,您可以查看此线程Do MSTest deployment items only work when present in the project test settings file?

【讨论】:

    猜你喜欢
    • 2022-07-22
    • 2021-02-06
    • 2019-12-02
    • 2021-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多