本文へスキップ
Skillpedia
テスト40k · #7349

pytest-coverage

できること

このツールは、コードがすべてテストされているかを確認するのに役立ちます。テストされていない部分のコードを示すので、テストを追加できます。

使う場面

  • ✓テストがすべてのコードをカバーしているか確認したいとき。
  • ✓テストのないコードの部分を見つける必要があるとき。
  • ✓コードの100%をテストすることを目指しているとき。

スキルのリンク

https://github.com/github/awesome-copilot/blob/main/skills/pytest-coverage/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/github/awesome-copilot/blob/main/skills/pytest-coverage/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“プロジェクトのテストカバレッジを確認して、テストが不足している箇所を教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

ツールはテストを実行し、どの行のコードが実行されたかを確認します。テストされなかった行を「!」でマークしたレポートを作成します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

The goal is for the tests to cover all lines of code.

Generate a coverage report with:

pytest --cov --cov-report=annotate:cov_annotate

If you are checking for coverage of a specific module, you can specify it like this:

pytest --cov=your_module_name --cov-report=annotate:cov_annotate

You can also specify specific tests to run, for example:

pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate

Open the cov_annotate directory to view the annotated source code. There will be one file per source file. If a file has 100% source coverage, it means all lines are covered by tests, so you do not need to open the file.

For each file that has less than 100% test coverage, find the matching file in cov_annotate and review the file.

If a line starts with a ! (exclamation mark), it means that the line is not covered by tests. Add tests to cover the missing lines.

Keep running the tests and improving coverage until all lines are covered.

よくある質問

「コードカバレッジ」とは何ですか?

テストによってコードのどの部分が実行されたかを示す指標です。目標は100%のコードがカバーされている状態です。

「cov_annotate」ディレクトリとは何ですか?

ツールが、コードのどの行がテストされ、どの行がテストされなかったかを行ごとに示すファイルを保存するフォルダです。

テストを追加する必要があるかどうかはどうすればわかりますか?

レポート内のコードファイルに「!」でマークされた行がある場合、それらの行はテストされていないので、テストを追加する必要があります。

詳細

作者による元の説明

Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.

repo: github/awesome-copilot

人気

GitHubのスター
40k
ランキング
#7349
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル