dsccommunity / dsccommunity/DscResource.Test

`Get-CodeCoverageResult`: New command proposal

Open
#170 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
6
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring

It is very complicated to get the code coverage for a certan function or class through CLI. Suggest adding a command that can make it less difficult:

Invoke-PesterWithCodeCoverage: runs Pester with required configuration and returns a PesterObject. The command should take an optional PesterConfiguration parameter, but use default if not specified.

Get-CodeCoverageResult: The command should take the parameters:

PesterObject (mandatory)
Name (optional, array of class and function names being tested)
AddSource (optional, only applicable when built module using ModuleBuilder)
Type (optional, either Missed, Executed or All - defaults to Missed only)

Should add a new property Type to the resulting objects with Missed or Executed

Returns the CommandsMissed

$config = New-PesterConfiguration
$config.Run.Path = @('<test paths>')
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Path = @('./output/builtModule/<ModuleName>')
$config.CodeCoverage.CoveragePercentTarget = 0
$config.Output.Verbosity = 'None'
$config.Run.PassThru = $true
$result = Invoke-Pester -Configuration $config
# After running above, get all commands that was missed with a reference to the SourceLineNumber in SourceFile.
$result.CodeCoverage.CommandsMissed | Where-Object { $_.Function -eq '<FunctionName>' -or $_.Class -eq '<ClassName>' } | Convert-LineNumber -PassThru | Select-Object Class, Function, Command, SourceLineNumber, SourceFile
Steps to reproduce the problem
Expected behavior
Current behavior
Suggested solution to the issue
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the module that was used

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reviewing the existing Invoke-Pester configuration and the PesterObject CodeCoverage.CommandsMissed output described in the issue, then determine how the proposed commands and Type, Name, and AddSource parameters should integrate. Done means the requested missed, executed, and filtered coverage results are available through the proposed CLI commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.