Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PwshAddict opened this issue Jun 25, 2020 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@PwshAddict
Copy link

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.

@ChrisLGardner
Copy link
Collaborator

Thanks, I know why this is happening (can't remember if there's a github issue on the main repo for it) and know how I'll fix it here. I'll add it to my list to look at as soon as I get some time.

@ChrisLGardner ChrisLGardner self-assigned this Jun 25, 2020
@ChrisLGardner ChrisLGardner added the bug Something isn't working label Jun 25, 2020
@PwshAddict
Copy link
Author

I was able to resolve it by creating the [pesterconfiguration] object first and then update the settings along the way. It's on my fork at the moment. If this how you were thinking, I can create a PR for it.

@ChrisLGardner
Copy link
Collaborator

Yeah, that's basically the issue. It doesn't cast the nested hashtables to the right thing for some reason. If you've got a PR then that'd be welcome.

@PwshAddict
Copy link
Author

PR sent and added you as a collaborator on my repo. Didn't see a way to make you an owner.

@ChrisLGardner
Copy link
Collaborator

Fixed in #39. Thanks for the help there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants