My test and function code were in the same directory and I was getting the results of code coverage which was working fine.
However after splitting the code into seperate directories Src
and Tests
I am now seeing the error below regarding paths:
Resolve-CoverageInfo : Could not resolve coverage path
How can I ensure that data is written to my code coverage file?
The way I am running Pester is through setting config then using the Invoke-Pester
command. See below for example:
$files = Get-ChildItem .\Tests -File -Recurse -Include *.*
$config = [PesterConfiguration]::Default
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Path = $files
$config.CodeCoverage.OutputFormat = "NUnitXml"
$config.CodeCoverage.OutputPath = "$result_folder/test-coverage.xml"
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = "$result_folder/test-results.xml"
$config.Filter.Tag = $TAG
Invoke-Pester -Configuration $config
When I check to see if the test-coverage.xml
file is generated it is, however the file is empty.