Skip to content

CodeCoverage.xml fails to include all files from -CodeCoverageFolder  #38

Closed
@PwshAddict

Description

@PwshAddict

Where are you running it?

You can run the extensions in the cloud or on-premise

  • Azure DevOps Service (VSTS)

Version of Extension/Task

10.1.17

Expected behaviour and actual behaviour

I expected all .ps1 files to be used for the codecoverage.xml file but only the ones in the ./tests folder show results.

Steps to reproduce the problem

Set -CodeCoverageFolder . or to the base folder
├───.vscode
├───docs
│ └───images
├───ModuleFolder
│ ├───private
│ └───public
├───TestResults
└───Tests

azure-pipelines.yml file:

 - task: Pester@10
      displayName: Pester Test Runner
      inputs:
        TestFolder: './tests'
        resultsFile: '$(Common.TestResultsDirectory)/Test-Pester.XML'
        CodeCoverageOutputFile: '$(Common.TestResultsDirectory)/CC-Pester.XML'
        usePSCore: ${{ parameters.pscore }}
        CodeCoverageFolder: '$(Build.Repository.LocalPath)/'
        PesterVersion: OtherVersion
        preferredPesterVersion: 5.0.2
        additionalModulePath: '$(System.DefaultWorkingDirectory)/**/*.psm1'

Findings during testing

$pesterConfig is correct and $pesterconfig.CodeCoverage.Path returns all the files.

$PesterConfig['CodeCoverage'] = $CodeCoverage

if (-not([String]::IsNullOrWhiteSpace($ScriptBlock))) {
    $ScriptBlockObject = [ScriptBlock]::Create($ScriptBlock)

    $ScriptBlockObject.Invoke()
}

$result = Invoke-Pester -Configuration  ([PesterConfiguration]$PesterConfig)

However, when the configuration object is created, ([PesterConfiguration]$PesterConfig).CodeCoverage.Path.Value is an empty array.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions