0

I'm trying to start a unit test in Azure Pipeline which opens an external file (myReport.rdl). The goal is to check, if the DataSets passed to the LocalReport class are harmoniously with report definition. Unfortunately I'm getting following error:

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

How to copy the .rdl file to the right place? Is there any other solution to that?

Code

      var localReport = new LocalReport(); // Microsoft.Reporting.WinForms
      localReport.ReportPath = ReportPath; // Reports/myReport.rdl 
      ... 
      localReport.Render("PDF", DeviceInfo, out _, out _, out _, out _, out var warnings);
mazaneicha
  • 8,794
  • 4
  • 33
  • 52
Patryk
  • 3
  • 1
  • 3

1 Answers1

0

From the error you mentioned in your question. I guess you are using attribute [DeploymentItem(string filePath, string outputDirectory)]. The test task will always copy the file specified in deploymentItem filePath to this directory "../Out/outputDirectory(the outputdirectory you specified)/file".

For example: [DeploymentItem(@"MyData/myReport.rdl", "Reports")].
myReport.rdl will be copied to “d:\a\1\s\TestResults\Deploy_**********\Out\Reports\myReport.rdl". To use myReport.rdl in your test method, you need to point your ReportPath = @"Reports \myReport.rdl".

If you do not specify the outputDirectory like below example: [DeploymentItem(@”MyData/myReport.rdl”)].
myReport.rdl will be copied to d:\a\1\s\TestResults\Deploy_**********\Out\myReport.rdl". To use myReport.rdl in your test method, you can point your ReportPath = "myReport.rdl".

For more information you can check this thread Do MSTest deployment items only work when present in the project test settings file?

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43