Skip to content

100% code coverage #133

Description

@stiwicourage

Plan for 100% code coverage in selected files

Purpose

This plan describes a focused testing effort to raise code coverage to 100% in the files you identified.

The work should be:

  • incremental
  • reviewable
  • driven by existing test suites where that makes sense
  • focused on stable contracts rather than brittle implementation details

The goal is not just to “hit lines,” but to cover all relevant branches, error paths, and small helper functions in a way that keeps the codebase maintainable.

Primary goal

The following files are in scope for this plan and should end up at 100% coverage:

  • src/private/quality/WriteNovaPesterTestResultReport.ps1
  • src/private/release/ImportNovaPublishedLocalModule.ps1
  • src/private/package/GetNovaPackageMetadataList.ps1
  • src/private/package/MergeNovaPackageSettingTable.ps1
  • src/private/cli/GetNovaCliHelpRequest.ps1
  • src/private/package/GetNovaManifestValue.ps1
  • src/private/package/GetNovaPackageFileName.ps1
  • src/private/quality/WriteNovaPesterTestResultArtifact.ps1
  • src/private/package/GetNovaPackageSettingValue.ps1
  • src/private/package/GetNovaPackageUploadAuthHeaderValue.ps1
  • src/private/release/GetNovaLocalPublishActivation.ps1
  • src/private/update/GetNovaPrereleaseModuleUpdateConfirmationPrompt.ps1
  • src/private/package/GetNovaPackageArtifactPatternInfo.ps1
  • src/private/package/GetNovaPackageAuthorList.ps1
  • src/private/package/GetNovaPackageMetadata.ps1
  • src/private/package/GetNovaPackageOutputDirectory.ps1
  • src/private/package/GetNovaPackageUploadStatusCode.ps1
  • src/private/update/ConfirmNovaPrereleaseModuleUpdate.ps1
  • src/private/cli/AddNovaCliOptionValue.ps1
  • src/private/cli/ConfirmNovaCliAction.ps1
  • src/private/cli/FormatNovaCliCommandHelp.ps1
  • src/private/cli/GetNovaCliForwardingParameterSet.ps1
  • src/private/cli/GetNovaCliInstalledVersion.ps1
  • src/private/package/AssertNovaPackageMetadata.ps1
  • src/private/package/GetNovaPackageArtifactType.ps1
  • src/private/package/InitializeNovaPackageOutputDirectory.ps1
  • src/private/package/JoinNovaPackageUploadUrl.ps1
  • src/private/package/NewNovaPackageArtifacts.ps1
  • src/private/package/ResolveNovaPackageUploadTypeList.ps1
  • src/private/package/TestNovaPathContainsPath.ps1
  • src/private/quality/InitializeNovaPesterExecutionConfiguration.ps1
  • src/private/release/GetNovaInstalledProjectManifestPath.ps1
  • src/private/release/GetNovaPublishedLocalManifestPath.ps1
  • src/private/release/GetNovaResolvedPublishParameterMap.ps1
  • src/private/shared/GetNovaModulePsDataValue.ps1
  • src/private/shared/GetNovaProjectPackageOutputDirectorySettingsTable.ps1
  • src/private/shared/GetNovaResolvedProjectManifestSettings.ps1
  • src/private/update/InvokeNovaPowerShellScriptWithTimeout.ps1
  • src/public/InitializeNovaModule.ps1

Important working rules

  • Preserve existing behavior unless a test reveals a real defect.
  • Add tests in small batches of 3-6 files at a time.
  • Prefer extending existing test files before creating new suites.
  • Cover both happy paths and relevant edge/error paths.
  • When a helper is already close to 100%, cover the last missing branch precisely instead of broadening the test unnecessarily.
  • After each meaningful batch, relevant Code Health checks and safeguards must stay green.

Suggested test hosting

Use these existing test suites first:

  • tests/CoverageGaps.Cli.Tests.ps1

    • CLI helpers
    • update/confirm helpers with CLI-facing behavior
    • src/public/InitializeNovaModule.ps1
  • tests/CoverageGaps.ReleaseInternals.Tests.ps1

    • release helpers
    • local publish/import helpers
  • tests/RemainingHelperCoverage.Tests.ps1

    • package helpers
    • shared helpers
    • small utility helpers
  • tests/UpdateNotification.Tests.ps1

    • prerelease update confirmation helpers
  • tests/CiCoverage.Tests.ps1

    • quality/Pester report helpers

Supplement with existing test-support files when small builders/stubs are needed:

  • tests/RemainingHelperCoverage.TestSupport.ps1
  • tests/UpdateNotification.TestSupport.ps1
  • tests/CoverageCompletion.TestSupport.ps1
  • tests/NovaCommandModel.PackageUpload.TestSupport.ps1

Prioritized execution plan

Phase 0 — Confirm the baseline and split the work

  1. Confirm that the user-provided file list is the current source of truth.
  2. Cross-check the list against artifacts/coverage-low.txt after a fresh build/test run.
  3. Split the work into small, PR-friendly batches.
  4. Use this priority order:
    • first files with 0-40% coverage
    • then files with 40-85%
    • finally files with 85%+ where only a single branch is still missing

Phase 1 — Close the 0% and low-coverage gaps first

These files should be tackled first because they provide the biggest coverage gain and often have only a few clear branches:

  • src/private/quality/WriteNovaPesterTestResultReport.ps1
  • src/private/update/GetNovaPrereleaseModuleUpdateConfirmationPrompt.ps1
  • src/private/update/ConfirmNovaPrereleaseModuleUpdate.ps1
  • src/private/release/ImportNovaPublishedLocalModule.ps1
  • src/private/quality/WriteNovaPesterTestResultArtifact.ps1
  • src/private/package/GetNovaManifestValue.ps1
  • src/private/release/GetNovaLocalPublishActivation.ps1

For each of these files, add tests that explicitly cover:

  • normal return value
  • missing input or empty values
  • any error paths or delegation calls
  • return-value structure or side effect, where relevant

Phase 2 — Finish the package metadata/settings/helpers area

Then take the package-related helpers in a grouped but still small and readable sequence of batches:

  • src/private/package/GetNovaPackageMetadataList.ps1
  • src/private/package/MergeNovaPackageSettingTable.ps1
  • src/private/package/GetNovaPackageSettingValue.ps1
  • src/private/package/GetNovaPackageMetadata.ps1
  • src/private/package/GetNovaPackageAuthorList.ps1
  • src/private/package/AssertNovaPackageMetadata.ps1
  • src/private/package/GetNovaPackageArtifactPatternInfo.ps1
  • src/private/package/GetNovaPackageArtifactType.ps1
  • src/private/package/GetNovaPackageOutputDirectory.ps1
  • src/private/package/GetNovaPackageFileName.ps1
  • src/private/package/GetNovaPackageUploadStatusCode.ps1
  • src/private/package/GetNovaPackageUploadAuthHeaderValue.ps1
  • src/private/package/InitializeNovaPackageOutputDirectory.ps1
  • src/private/package/JoinNovaPackageUploadUrl.ps1
  • src/private/package/NewNovaPackageArtifacts.ps1
  • src/private/package/ResolveNovaPackageUploadTypeList.ps1
  • src/private/package/TestNovaPathContainsPath.ps1

The tests should specifically ensure:

  • empty and missing settings are handled correctly
  • merge order and override rules are covered precisely
  • metadata fields are returned correctly for both present and missing manifest fields
  • URL/path helpers handle separators, empty segments, and simple edge cases
  • artifact/type mapping and status codes have complete branch coverage

Phase 3 — Bring CLI helpers to 100%

Then focus on the CLI layer:

  • src/private/cli/GetNovaCliHelpRequest.ps1
  • src/private/cli/AddNovaCliOptionValue.ps1
  • src/private/cli/ConfirmNovaCliAction.ps1
  • src/private/cli/FormatNovaCliCommandHelp.ps1
  • src/private/cli/GetNovaCliForwardingParameterSet.ps1
  • src/private/cli/GetNovaCliInstalledVersion.ps1

Add or extend tests for:

  • root help vs command help vs long/short help
  • option-value parsing with valid and invalid argument combinations
  • confirm behavior for accepted, rejected, and non-interactive/redirected scenarios
  • help formatting with all relevant sections, docs links, and edge cases
  • forwarding parameter sets with and without ShouldProcess-related parameters
  • installed version with and without prerelease metadata

Phase 4 — Release/shared/public wrappers

Finish with the smaller wrappers and project/publish helpers:

  • src/private/release/GetNovaInstalledProjectManifestPath.ps1
  • src/private/release/GetNovaPublishedLocalManifestPath.ps1
  • src/private/release/GetNovaResolvedPublishParameterMap.ps1
  • src/private/shared/GetNovaModulePsDataValue.ps1
  • src/private/shared/GetNovaProjectPackageOutputDirectorySettingsTable.ps1
  • src/private/shared/GetNovaResolvedProjectManifestSettings.ps1
  • src/private/update/InvokeNovaPowerShellScriptWithTimeout.ps1
  • src/public/InitializeNovaModule.ps1

Here the tests should mainly protect:

  • path construction
  • fallback/default values
  • delegation to underlying helpers/commands
  • timeout/error behavior
  • the public wrapper as a thin delegator with a stable contract

Concrete batch suggestions

Prefer to work in this order:

  1. Batch A

    • WriteNovaPesterTestResultReport
    • WriteNovaPesterTestResultArtifact
    • InitializeNovaPesterExecutionConfiguration
  2. Batch B

    • GetNovaPrereleaseModuleUpdateConfirmationPrompt
    • ConfirmNovaPrereleaseModuleUpdate
    • InvokeNovaPowerShellScriptWithTimeout
  3. Batch C

    • ImportNovaPublishedLocalModule
    • GetNovaLocalPublishActivation
    • GetNovaInstalledProjectManifestPath
    • GetNovaPublishedLocalManifestPath
    • GetNovaResolvedPublishParameterMap
  4. Batch D

    • package metadata/settings helpers
  5. Batch E

    • package path/URL/output/artifact helpers
  6. Batch F

    • CLI helpers
  7. Batch G

    • shared helpers
    • src/public/InitializeNovaModule.ps1

Test strategy by helper type

Small pure functions

Use table-driven tests where appropriate to cover:

  • null/empty input
  • normal value
  • fallback value
  • invalid input

Delegators and wrappers

Use mocks and verify:

  • the correct helper/command is called
  • parameters are forwarded correctly
  • the return value or error is translated stably

Formatters and report writers

Verify:

  • content
  • ordering
  • absence/presence of sections
  • encoding/output path where relevant

Interactive/timeout-based helpers

Isolate side effects behind mocks or controlled test seams and cover:

  • success path
  • negative path
  • timeout/cancel path

Validation after each batch

Run at least the relevant focused tests plus the build:

pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-NovaBuild'
pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-Pester ./tests/CiCoverage.Tests.ps1 -Output Detailed'
pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-Pester ./tests/CoverageGaps.Cli.Tests.ps1 -Output Detailed'
pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-Pester ./tests/CoverageGaps.ReleaseInternals.Tests.ps1 -Output Detailed'
pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-Pester ./tests/RemainingHelperCoverage.Tests.ps1 -Output Detailed'
pwsh -NoLogo -NoProfile -Command 'Set-Location "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools"; Invoke-Pester ./tests/UpdateNotification.Tests.ps1 -Output Detailed'

When a larger group is finished, also run the full quality flow:

zsh -lc 'pwsh -NoLogo -NoProfile -File "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools/run.ps1" > /tmp/novamoduletools-run-coverage100.log 2>&1; rc=$?; tail -n 80 /tmp/novamoduletools-run-coverage100.log | cat; echo "EXIT:$rc"'

And always:

zsh -lc 'cd "/Users/stiwi.courage/workspace/couragedk/NovaModuleTools" && git --no-pager diff --check'

Code Health and safeguard requirements

After each meaningful batch:

  1. Run a Code Health review on the touched test files.
  2. Keep the target at 10.0, or refactor if the test code becomes too complex.
  3. Run the pre-commit Code Health safeguard before marking the work as done.

Documentation review

After each change, evaluate whether these need updates:

  • README.md
  • CONTRIBUTING.md
  • CHANGELOG.md

For this plan, documentation changes are normally not expected because the work is primarily about internal test coverage. If the test work reveals a real user-facing behavior change or a new contributor expectation, the documentation must be updated.

Definition of done

The work is only done when all of the following are true:

  1. All files in the scope list are at 100% code coverage.
  2. No public command contracts have changed unintentionally.
  3. Relevant test suites have been updated with stable, readable tests.
  4. Invoke-NovaBuild passes.
  5. Relevant Pester suites pass.
  6. run.ps1 passes.
  7. git diff --check is clean.
  8. Code Health safeguards are green.
  9. The documentation review has been completed and its conclusion documented.

Progress tracking

Coverage batches

  • Batch A — quality helpers
  • Batch B — update helpers
  • Batch C — release helpers
  • Batch D — package metadata/settings helpers
  • Batch E — package artifact/path/output helpers
  • Batch F — CLI helpers
  • Batch G — shared/public wrappers

Validation checklist

  • Invoke-NovaBuild passes
  • CiCoverage.Tests.ps1 passes
  • CoverageGaps.Cli.Tests.ps1 passes
  • CoverageGaps.ReleaseInternals.Tests.ps1 passes
  • RemainingHelperCoverage.Tests.ps1 passes
  • UpdateNotification.Tests.ps1 passes
  • run.ps1 passes
  • git diff --check passes
  • Code Health safeguard passes
  • Docs reviewed

Expected final report

When the work is complete, the final report should include at minimum:

  1. Which coverage gaps were closed
  2. Which files and test suites were updated
  3. How the tests were grouped and why
  4. Which edge/error paths gained coverage
  5. Validation commands and results
  6. Code Health results
  7. Documentation review and any updates
  8. Any remaining follow-up ideas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions