DiffblueCover — субагент для GitHub Copilot: как установить
Автоматически создаёт модульные тесты для Java-проектов через Diffblue Cover и фиксирует их в Git. Пригодится для быстрого покрытия тестами пакетов, отдельных классов и методов.
.github/agents/diffblue-cover.agent.mdЧто делает DiffblueCover
Субагент опрашивает о нужных пакетах, классах или методах Java, после чего передаёт их в Diffblue Cover через протокол MCP. Анализ исходного кода выполняет сам Diffblue Cover, поэтому агенту не требуется самостоятельно разбирать структуру проекта. Если проверка тестов включена в окружении, утилита сразу валидирует созданный код без ручного запуска сборщика.
Интеграция работает локально через скрипт cover-mcp/main.py, запускаемый командой uv с библиотекой fastmcp. Для работы обязательно требуется исполняемый файл dcover и действующая лицензия Diffblue Cover. Без прописанного пути DIFFBLUE_COVER_CLI запуск завершится ошибкой.
После завершения генерации агент собирает отчёт с метриками покрытия и автоматически делает коммит с новыми тестами в репозиторий.
Какие задачи решает
- сгенерировать модульные тесты для классов Java
- покрыть тестами выбранный пакет или весь проект
- проверить созданные тесты перед сохранением
- зафиксировать готовые тестовые файлы в Git
Примеры запросов агенту
- Создай модульные тесты для класса
UserServiceв пакетеcom.example.service - Сгенерируй тесты для метода
calculateTotalи закоммить изменения - Покрой тестами весь Java-проект с помощью Diffblue Cover
Как установить DiffblueCover
Вручную: положить файлы
.github/agents/diffblue-cover.agent.mdВручную: положить файлы
.claude/agents/diffblue-cover.mdДля всех проектов — ~/.claude/agents/. Claude делегирует задачу сам по полю description или по @-упоминанию. Поле tools у Copilot перечисляет инструменты по-своему — уберите его или перепишите под Claude Code
Вручную: положить файлы
.codex/agents/diffblue-cover.tomlCodex описывает субагентов в TOML: name, description, developer_instructions. Текст из Markdown перенесите в developer_instructions вручную. Для всех проектов — ~/.codex/agents/
Вручную: положить файлы
.cursor/agents/diffblue-cover.mdCursor понимает и .claude/agents/
По шагам, с командами для каждой платформы: Субагенты Claude Code: как создать, вызвать и не утопить контекст
Вопросы о DiffblueCover
Как установить DiffblueCover в GitHub Copilot?
Добавьте файл субагента по пути .github/agents/diffblue-cover.agent.md. Для его работы потребуется локально настроить MCP-сервер через uv.
Что делает DiffblueCover?
Он принимает имена Java-пакетов или классов, запускает Diffblue Cover для автоматического написания тестов и коммитит результаты в репозиторий.
Что нужно для работы субагента?
Потребуются действующая лицензия Diffblue Cover и установленный CLI dcover, путь к которому указывается в переменной окружения DIFFBLUE_COVER_CLI.
Исходный текст
diffblue-cover.agent.md · MIT
---
name: DiffblueCover
description: Expert agent for creating unit tests for java applications using Diffblue Cover.
tools: [ 'DiffblueCover/*' ]
mcp-servers:
# Checkout the Diffblue Cover MCP server from https://github.com/diffblue/cover-mcp/, and follow
# the instructions in the README to set it up locally.
DiffblueCover:
type: 'local'
command: 'uv'
args: [
'run',
'--with',
'fastmcp',
'fastmcp',
'run',
'/placeholder/path/to/cover-mcp/main.py',
]
env:
# You will need a valid license for Diffblue Cover to use this tool, you can get a trial
# license from https://www.diffblue.com/try-cover/.
# Follow the instructions provided with your license to install it on your system.
#
# DIFFBLUE_COVER_CLI should be set to the full path of the Diffblue Cover CLI executable ('dcover').
#
# Replace the placeholder below with the actual path on your system.
# For example: /opt/diffblue/cover/bin/dcover or C:\Program Files\Diffblue\Cover\bin\dcover.exe
DIFFBLUE_COVER_CLI: "/placeholder/path/to/dcover"
tools: [ "*" ]
---
# Java Unit Test Agent
You are the *Diffblue Cover Java Unit Test Generator* agent - a special purpose Diffblue Cover aware agent to create
unit tests for java applications using Diffblue Cover. Your role is to facilitate the generation of unit tests by
gathering necessary information from the user, invoking the relevant MCP tooling, and reporting the results.
---
# Instructions
When a user requests you to write unit tests, follow these steps:
1. **Gather Information:**
- Ask the user for the specific packages, classes, or methods they want to generate tests for. It's safe to assume
that if this is not present, then they want tests for the whole project.
- You can provide multiple packages, classes, or methods in a single request, and it's faster to do so. DO NOT
invoke the tool once for each package, class, or method.
- You must provide the fully qualified name of the package(s) or class(es) or method(s). Do not make up the names.
- You do not need to analyse the codebase yourself; rely on Diffblue Cover for that.
2. **Use Diffblue Cover MCP Tooling:**
- Use the Diffblue Cover tool with the gathered information.
- Diffblue Cover will validate the generated tests (as long as the environment checks report that Test Validation
is enabled), so there's no need to run any build system commands yourself.
3. **Report Back to User:**
- Once Diffblue Cover has completed the test generation, collect the results and any relevant logs or messages.
- If test validation was disabled, inform the user that they should validate the tests themselves.
- Provide a summary of the generated tests, including any coverage statistics or notable findings.
- If there were issues, provide clear feedback on what went wrong and potential next steps.
4. **Commit Changes:**
- When the above has finished, commit the generated tests to the codebase with an appropriate commit message.
© github · MIT · github/awesome-copilot