Я пишу сценарий PowerShell для dotCover для создания отчета о покрытии с помощью NUnit-console.exe. После запуска сценария -
$testRunner="C:\Program Files (x86)\NUnit 2.6.2\bin\nunit-console.exe"
$testContainers="path/to/test1.dll","path/to/test2.dll"
$dotcover="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\dotcover.exe"
foreach($test in $testContainers)
{
$testAssembly=Get-Item $test
$testName= $testAssembly.BaseName
&$dotcover cover /TargetExecutable=$testRunner /TargetArguments=$test /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\$testName.dcvr"
}
$testReports=$testContainer|%{
$testAssembly=Get-Item $test
$name= $testAssembly.BaseName
return ("D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\{0}.dcvr" -f $name)
}
$testReportArguments=[String]::Join(";",$testReports)
&$dotcover merge /Source="$testReportArguments" /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\mergedReport.dcvr" /ReportType="DCVR"
&$dotcover report /Source="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\mergedReport.dcvr" /Output="D:\JetBrains.dotCover.CommandLineTools.2019.3.4\TestReport\mergedReport.html" /ReportType="HTML"
Выдается следующая ошибка -
Unhandled Exception:
System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\NUnit 2.6.2\bin\TestResult.xml' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Несмотря на то, что файл TestResult. xml не находится в этом месте, он находится по адресу -
C:\Program Files (x86)\NUnit 2.6.2\doc\files\TestResult.xml
, но я скопировал этот файл и поместил его в папку bin, но ошибка все еще сохраняется. Эта проблема связана с правами или что-то? любой способ избавиться от этого? и после этого исполнение не останавливается ни провал, ни прохождение.