0

我正在尝试在 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);
4

1 回答 1

0

根据您在问题中提到的错误。我猜你正在使用属性 [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"。

有关更多信息,您可以查看此线程 MSTest 部署项是否仅在项目测试设置文件中存在时才有效?

于 2019-08-06T07:16:21.473 回答