Prompt file imported from stiwicourage/NovaModuleTools (
.github/prompts/improve-test-coverage.prompt.md). Copyright stays with the author.
Improve NovaModuleTools test coverage
Invoke with
@.github/prompts/improve-test-coverage.prompt.md. Delegates to thetest-engineeragent.
Improve changed-code coverage in NovaModuleTools without lowering maintainability.
Required process
- Identify the exact uncovered file and line or branch.
- If no uncovered lines or branches are found, report that coverage is already complete and halt. If
artifacts/coverage.xmlis missing or stale, regenerate it by runningInvoke-NovaTestbefore proceeding. - Read the nearby production code and the most relevant existing test/support files.
- Place new tests in the source-mirrored path under
tests/by default: one focused.Tests.ps1file per coveredsrc/**/*.ps1file. If no corresponding.Tests.ps1file exists yet, create it with the standard file header and an emptyDescribeblock before adding the first test. Do not add tests to an unrelated existing file. - Use an existing guardrail or integration test only when it intentionally owns genuinely cross-cutting behavior. When built-module behavior of a single public command needs validation, use
tests/public/<Command>.Integration.Tests.ps1instead. For cross-cutting ownership, add a comment at the top of the integration test file in the format# Cross-cutting owner: <reason>. - Use
.github/instructions/testing-policy.instructions.mdas the test-design source of truth; keep new or heavily changed tests focused, isolated, and easy to scan. - Follow
.github/instructions/psscriptanalyzer.instructions.mdwhen test code or test helpers change. Prefer./scripts/build/Invoke-ScriptAnalyzerCI.ps1for repo-standard analyzer runs, and use directInvoke-ScriptAnalyzeronly for focused local checks that reuse the repo-approved settings. - Add the smallest test that proves the missing behavior.
- If setup is duplicated, refactor the tests before adding more assertions.
- Validate in this order:
- Always run
Invoke-NovaTest. - If
Invoke-NovaTestexits with an error or test failures, stop immediately, report the failure output verbatim, and do not proceed. - Run
Test-NovaBuildonly if any*.Integration.Tests.ps1file was added, removed, or had its# Cross-cutting owner: <reason>comment added or removed. - If
Test-NovaBuildexits with an error or test failures, stop immediately, report the failure output verbatim, and do not proceed. - Run the repository quality loop only if any
src/**/*.ps1production file was modified. - Never use
Invoke-Pesterdirectly for Nova-managed validation.
- Always run
- Recheck CodeScene coverage or Code Health if that was the original failure. If the original failure type is not stated in the conversation, recheck CodeScene as the default final step.
Repository-specific reminders
- Many tests expect a built
dist/NovaModuleToolsmodule. - The CI coverage flow writes
artifacts/coverage.xml. - Use
Invoke-NovaTestfor unit coverage validation andTest-NovaBuildfor build-validation integration coverage; directInvoke-Pestercan miss Nova-specific strict-mode behavior. - Keep public command unit coverage in
tests/public/<Command>.Tests.ps1. Usetests/public/<Command>.Integration.Tests.ps1when built-module behavior of that public command needs validation, and reserve existing cross-cutting guardrail or integration tests for behavior that intentionally spans multiple commands or workflows. - For destructive or environment-coupled public commands, prefer safe
-WhatIfintegration coverage when that still provesShouldProcess, routing, and output behavior. - Do not "fix" coverage by weakening assertions or suppressing CodeScene warnings.