Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
New parameter -CodeCoveragePath, and adds Modules folder (#270)
Browse files Browse the repository at this point in the history
- Add a new parameter `-CodeCoveragePath` in the function
  `Invoke-AppveyorTestScriptTask` to be able to add one or more relative
  paths which will be searched for PowerShell modules files (.psm1) to be used
  for evaluating code coverage (issue #114).
- The Modules folder, in the resource module root path, was added as a
  default path to be searched for PowerShell modules files (.psm1) to be
  used for evaluating code coverage.
  • Loading branch information
johlju committed Aug 15, 2018
1 parent cf36b1d commit ab96f03
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 44 deletions.
23 changes: 18 additions & 5 deletions AppVeyor.psm1
Expand Up @@ -132,6 +132,14 @@ function Invoke-AppveyorInstallTask
integration test with a specific order has run.
This will also enable running unit tests and integration tests in a
Docker Windows container.
.PARAMETER CodeCoveragePath
One or more relative paths to PowerShell modules, from the root module
folder. For each relative folder it will recursively search the first
level subfolders for PowerShell module files (.psm1).
Default to 'DSCResources', 'DSCClassResources', and 'Modules'.
This parameter is ignored when testing the DscResource.Tests repository
since that repository is treated differently, and has hard-coded paths.
#>
function Invoke-AppveyorTestScriptTask
{
Expand Down Expand Up @@ -176,7 +184,15 @@ function Invoke-AppveyorTestScriptTask

[Parameter(ParameterSetName = 'Default')]
[Switch]
$RunTestInOrder
$RunTestInOrder,

[Parameter(ParameterSetName = 'Default')]
[String[]]
$CodeCoveragePath = @(
'DSCResources',
'DSCClassResources',
'Modules'
)
)

# Convert the Main Module path into an absolute path if it is relative
Expand Down Expand Up @@ -275,10 +291,7 @@ function Invoke-AppveyorTestScriptTask
Define the folders to check, if found add the path for
code coverage.
#>
$possibleModulePaths = @(
'DSCResources',
'DSCClassResources'
)
$possibleModulePaths = $CodeCoveragePath

foreach ($possibleModulePath in $possibleModulePaths)
{
Expand Down
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -377,6 +377,14 @@ Pester code coverage, which the first two sections cover.
1. On the call to `Invoke-AppveyorTestScriptTask`, make sure you have
`-CodeCoverage` specified. This will enable Pester code coverage.

It is possible to control which relative paths, from the root module folder, are
evaluated for code coverage.
By specifying one or more relative paths in the parameter `-CodeCoveragePath`
each path is searched for PowerShell modules files (.psm1). For each relative
folder it will look in the root of the relative path, and also recursively
search the first level subfolders, for PowerShell module files (.psm1).
Defaults to the relative paths 'DSCResources', 'DSCClassResources', and 'Modules'.

#### Repository using `-Type 'Harness'` for `Invoke-AppveyorTestScriptTask`

1. Make sure you are properly generating pester code coverage in the repository
Expand Down Expand Up @@ -974,6 +982,11 @@ Contributors that add or change an example to be published must make sure that
- Added Rule Name to PS Script Analyzer custom rules
- Added PsScript Analyzer Rule Name to Write-Warning output in meta.tests
- Removed sections 'Goals' and 'Git and Unicode' as they have become redundant.
- Add a new parameter `-CodeCoveragePath` in the function
`Invoke-AppveyorTestScriptTask` to be able to add one or more relative
paths which will be searched for PowerShell modules files (.psm1) to be used
for evaluating code coverage
([issue #114](https://github.com/PowerShell/DscResource.Tests/issues/114)).
### 0.2.0.0
Expand Down

0 comments on commit ab96f03

Please sign in to comment.