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

How to use Coverage tests? #37

Open
Mxrcon opened this issue Dec 21, 2022 · 0 comments
Open

How to use Coverage tests? #37

Mxrcon opened this issue Dec 21, 2022 · 0 comments

Comments

@Mxrcon
Copy link

Mxrcon commented Dec 21, 2022

Description
Hey There 👋, Thank you for this template, It has been pretty useful for my work and I've been using it to start my projects.

This is not a feature request, It's more a Question regarding using coverage tests within this template.

Describe the solution you'd like
I would like to have coverage tests generated by plaster while keep using the standard template provided by stucco.

Describe any alternatives you've considered
I've considered dropping the stucco template to use other build systems, but powershellbuild is what fit the best with my context.

Additional context
here is the header of my psakeFile.ps1

    $PSBPreference.Build.CompileModule = $false
    $PSBPreference.Help.DefaultLocale = 'en-US'
    $PSBPreference.Test.OutputFile = 'out/testResults.xml'
    $PSBPreference.Test.ImportModule = $true
    $PSBPreference.Test.CodeCoverage.Enabled  = $true
    $PSBPreference.Test.CodeCoverage.OutputFormat= "JaCoCo"
    $PSBPreference.Test.CodeCoverage.OutputFile= "out/CoverageResults.xml"

My problem is that my coverage results are like this:

Type: [Instruction]: 0.000%
Type: [Line]: 0.000%
Type: [Method]: 0.000%
Type: [Class]: 100.000%

I don't understand why I'm not getting coverage for methods, I'm not using any class on this project.

Here is my overall structure:

├── build.ps1
├── CHANGELOG.md
├── Dockerfile
├── LICENSE
├── makefile
├── psakeFile.ps1
├── README.md
├── requirements.psd1
├── resources
├── Module-Name
│   ├── Private
│   │   ├── Api-Versions
│   │   │   ├── health.ps1
│   │   │   ├── v1Search.ps1
│   │   │   └── v1Solve.ps1
│   │   └── Web-Pages
│   │       └── home_page.html
│   ├── Public
│   │   ├── Get-Binary.ps1
│   │   ├── Get-Version.ps1
│   │   ├── Start-Server.ps1
│   │   └── Test-Env.ps1
│   ├── Module-Name.psd1
│   └── Module-Name.psm1
└── tests
    ├── Endpoints
    │   ├── Health.tests.ps1
    │   ├── Search.tests.ps1
    │   └── Solve.tests.ps1
    ├── Help.tests.ps1
    ├── Manifest.tests.ps1
    ├── MetaFixers.psm1
    ├── Meta.tests.ps1
    ├── readme.md
    ├── ScriptAnalyzerSettings.psd1
    └── Unit
        └── Public
            └── Test-Env.tests.ps1

Here is my code coverage output:

Covered 55% / 75%. 20 analyzed Commands in 1 File.
Missed commands:

File            Class Function                   Line Command
----            ----- --------                   ---- -------
MetaFixers.psm1       ConvertTo-UTF8               19 $content = Get-Content -Raw -Encoding Unicode -Path $FileInfo.FullName
MetaFixers.psm1       ConvertTo-UTF8               20 [System.IO.File]::WriteAllText($FileInfo.FullName, $content, [System.Text.Encoding…
MetaFixers.psm1       ConvertTo-SpaceIndentation   33 $content = (Get-Content -Raw -Path $FileInfo.FullName) -replace "`t", '    '
MetaFixers.psm1       ConvertTo-SpaceIndentation   33 Get-Content -Raw -Path $FileInfo.FullName
MetaFixers.psm1       ConvertTo-SpaceIndentation   34 [IO.File]::WriteAllText($FileInfo.FullName, $content)
MetaFixers.psm1       Get-UnicodeFilesList         79 $root
MetaFixers.psm1       Get-UnicodeFilesList         79 Get-TextFilesList
MetaFixers.psm1       Get-UnicodeFilesList         79 Where-Object { Test-FileUnicode $_ }
MetaFixers.psm1       Get-UnicodeFilesList         79 Test-FileUnicode $_



Code Coverage:

Type: [Instruction]: 0.000%
Type: [Line]: 0.000%
Type: [Method]: 0.000%
Type: [Class]: 100.000%


Would you mind to guide me on how to add coverage tests as intended without stop using your template? I really Like it and would like to stick with it as long as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant