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

Simplify running code coverage for a single test file #387

Open
johlju opened this issue Jun 5, 2022 · 1 comment
Open

Simplify running code coverage for a single test file #387

johlju opened this issue Jun 5, 2022 · 1 comment
Labels
enhancement The issue is an enhancement request.

Comments

@johlju
Copy link
Collaborator

johlju commented Jun 5, 2022

Problem description

Currently when running ./build.ps1 -Task test -PesterPath ‘testfile’ it runs code coverage on all files in the built module result in a lot out missed lines (especially for big modules).

To be able to run code coverage for a single file using Invoke-Pester you have to pass a New-PesterConfiguration filled with the code script path and coverage path and settings. This can be complicated for new contributors.

Verbose logs

m/a

How to reproduce

n/a

Expected behavior

n/a

Current behavior

n/a

Suggested solution

We should simplify that by adding a CodeCovergePath to build.ps1 so it possible to write:

.\build.ps1 -Task test -PesterPath testfile -CodeCoveragePath code_script_file

It will then also use settings from the build configuration.

Operating system the target node is running

n/a

PowerShell version and build the target node is running

n/a

Module version used

n/a
@johlju
Copy link
Collaborator Author

johlju commented Jun 20, 2022

For this to work we need to get coverage for a specific source file in the built module (e.g. MOF-based DSC resource) using CodeCoveragePath, or a particular function inside the built module script file (.psm1) for modules using pattern Public/Private/Classes, using the same build.ps1 parameter CodeCoveragePath but pass an [System.Collections.IDictionary] like Pester expects. For the latter we need a way to single out the lines of an individual function or functions.

But it is not possible to pass an [System.Collections.IDictionary] to Pester due to issue pester/Pester#2190.

@johlju johlju added the enhancement The issue is an enhancement request. label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

No branches or pull requests

1 participant