Prompt file imported from juanroyofullstack/donet-aspire-server (
.github/prompts/run-tests-and-coverage.prompt.md). Copyright stays with the author.
Run tests and coverage
Run the .NET tests in this repository and generate a code coverage report, including an HTML version for visual inspection.
Instructions
- Use the test project path provided by the user.
- If no path is provided, default to:
- tests/NetAspireServer.Application.Tests.csproj
- Before running the tests, delete stale coverage artifacts from the repository root to avoid mixing old XMLs from other suites:
- rm -rf TestResults CoverageReport
- Run the command:
- dotnet test --collect:"XPlat Code Coverage" --results-directory TestResults --settings coverlet.runsettings
- After the test run, generate an HTML coverage report from the Cobertura XML with ReportGenerator using:
- reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"CoverageReport" -reporttypes:Html
- Show:
- the summary of the executed tests
- whether the coverage report was generated
- the path of the generated XML coverage file
- the path of the generated HTML coverage report
- If tests fail, stop and summarize the errors clearly.
Expected behavior
- Work from the repository root.
- Use coverage collection explicitly.
- Generate both the raw XML and the HTML report.
- If the project does not exist, report it and suggest the correct path.
