How to use GitHub Copilot for test coverage reports

View profile for Pamela Fox

I like to learn, teach, and create.

Accidentally discovered a new way to work with GitHub Copilot today: write new tests based off test coverage reports. Copilot (or I) run this command to generate a report of all the uncovered lines in the current diff: pytest --cov --cov-report=xml && \ diff-cover coverage.xml --html-report coverage_report.html && \ open coverage_report.html Then Copilot reviews the report, summarizes the uncovered situations, and proposes new test cases to add, or if the code is truly unreachable, suggests deleting it. Just another reason why you should add diff-cover (or similar tool) to your projects!

  • No alternative text description for this image
Jennifer Perret

Ex-Microsoft | Cloud, Security, AI, Data

2mo

Love this so much!

Like
Reply
Prafull Kotecha

Engineer | Solutions Architect | Mentor | AI Native Developer/Architect

1mo

Copying...

Like
Reply
James Reagan

AI engineer / 🇺🇸 US Marine Corps veteran

2mo

Very useful

Like
Reply
Keith Baldwin

I help Microsoft .NET Developers Integrate AI into Business Apps | I saw lumber and wood slabs

2mo

Great discovery, Pamela! Summarizing uncovered situations with Copilot is a very efficient approach. This kind of practical solution is exactly what we need more of in the industry. 🚀

See more comments

To view or add a comment, sign in

Explore content categories