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

Code coverage does not analyze code in all module files in this repository #208

Closed
johlju opened this issue Feb 3, 2018 · 3 comments
Closed

Comments

@johlju
Copy link
Contributor

johlju commented Feb 3, 2018

Currently when this repository is tested, the code coverage is only reported for the module files in the root folder.
Thats because the following code block does not add more than the modules in the root folder.

if (Test-Path -Path "$MainModulePath\DSCResources" )
{
$pesterParameters += @{
CodeCoverage = @(
"$env:APPVEYOR_BUILD_FOLDER\*.psm1"
"$env:APPVEYOR_BUILD_FOLDER\DSCResources\*.psm1"
"$env:APPVEYOR_BUILD_FOLDER\DSCResources\**\*.psm1"
)
}
}
else
{
$pesterParameters += @{
CodeCoverage = @(
"$env:APPVEYOR_BUILD_FOLDER\*.psm1"
)
}
}
}

Suggest we use the helper function Test-IsRepositoryDscResourceTests to see if we are testing this repository, and if so, add all the module files (.psm1) under sub folders as well. So we can get code coverage for all the helper modules like DscResource.AnalyzerRules, DscResource.CodeCoverage and DscResource.DocumentationHelper.

@PlagueHO
Copy link
Collaborator

PlagueHO commented Feb 3, 2018

Good call @johlju - this looks like a goo idea.

So there would be three different code coverage file patterns:

  1. Test Harness DSC repo
  2. Normal DSC repo
  3. DSCResources.Tests repo

So the else in your code block above could be replaced by an elseif (Test-IsRepositoryDscResourceTests)?

@johlju johlju changed the title Code coverage does analyze code in all module files in this repository Code coverage does not analyze code in all module files in this repository Feb 3, 2018
@johlju
Copy link
Contributor Author

johlju commented Feb 3, 2018

Yes my thought was three patterns. I think we need to add and elseif before the else in the block above, so that a new resource module that does not have a DSCResource module does get coverage (a extreme edge case).

I think new elseif-block should have the path $env:APPVEYOR_BUILD_FOLDER\**\*.psm1 as well as the path in else block (don’t think the former fetches modules in root?). So we could add an if-block inside the else-block, if that is less code rows.

@johlju
Copy link
Contributor Author

johlju commented Feb 4, 2018

Actually there will be these three file patterns since the code block that will change does not affect Harness-repos.

  1. Normal resource module repo with DSCResource-folder (repo with resources)
  2. Normal resource module repo without DSCResource-folder (repo without resources)
  3. DscResources.Tests repo

The second and the third might be able to be the same.

johlju added a commit to johlju/DscResource.Tests that referenced this issue Feb 4, 2018
- Added more tests for custom Script Analazyer rules to increased code coverage.
  These new tests call the Measure-functions directly.
- Changed so that DscResource.Tests repository can analyze code coverage for the
  helper modules (issue PowerShell#208).
johlju added a commit to johlju/DscResource.Tests that referenced this issue Mar 22, 2018
- Added more tests for custom Script Analazyer rules to increased code coverage.
  These new tests call the Measure-functions directly.
- Changed so that DscResource.Tests repository can analyze code coverage for the
  helper modules (issue PowerShell#208).
johlju added a commit to johlju/DscResource.Tests that referenced this issue Mar 27, 2018
- Added more tests for custom Script Analazyer rules to increased code coverage.
  These new tests call the Measure-functions directly.
- Changed so that DscResource.Tests repository can analyze code coverage for the
  helper modules (issue PowerShell#208).
johlju added a commit to johlju/DscResource.Tests that referenced this issue Apr 19, 2018
- Added more tests for custom Script Analazyer rules to increased code coverage.
  These new tests call the Measure-functions directly.
- Changed so that DscResource.Tests repository can analyze code coverage for the
  helper modules (issue PowerShell#208).
@johlju johlju closed this as completed in 8d4e55d Apr 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants