Автоисправление существующих тестов под корпоративные стандарты. Use when the user invokes /test-fix.
How this skill is triggered — by the user, by Claude, or both
Slash command
/bereke-business-test-gen:test-fixThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Converted from Claude Code command `/test-fix`.
Converted from Claude Code command
/test-fix. Review and adapt: hooks and MCP tool IDs may need manual mapping for Codex.
Автоматический рефакторинг существующих unit тестов для соответствия корпоративным стандартам.
| Режим | Описание | Приоритет |
|---|---|---|
--all | Все исправления | - |
--flow-verify | coVerify → FlowTestUtils.coVerifyFlowCall | HIGH |
--branches | Добавить тесты для непокрытых веток | HIGH |
--assertions | assertTrue → assertThat | MEDIUM |
--display-names | Добавить @DisplayName | LOW |
/test-fix --all feature/auth
/test-fix --flow-verify core/network
/test-fix --assertions core/domain
/test-fix --branches feature/payments/PaymentInteractorTest.kt
/test-fix --display-names feature/auth
Проблема: coVerify { flowMethod() } вызывает memory leak!
Исправление:
// ❌ BEFORE - Memory leak!
@Test
fun getDataFlow_success() = runTest {
repository.getDataFlow().test { ... }
coVerify { mockRepo.getDataFlow() }
}
// ✅ AFTER - Correct
@Test
fun getDataFlow_success() = runTest {
repository.getDataFlow().test { ... }
FlowTestUtils.coVerifyFlowCall {
mockRepo.getDataFlow()
}
}
Алгоритм:
find ${MODULE_PATH}/src/test -name "*Test.kt"
coVerify для Flow методов:
grep -n "coVerify.*Flow\|coVerify.*flow" ${TEST_FILE}
FlowTestUtils.coVerifyFlowCallВывод:
🔧 Flow Verify Fix Report
═══════════════════════════════════════════════════════
Module: feature/auth
Fixed files:
✅ AuthRepositoryTest.kt - 3 fixes
✅ LoginInteractorTest.kt - 1 fix
⏭️ TokenValidatorTest.kt - no Flow methods
Total: 4 memory leaks fixed!
Проблема: Тесты покрывают только happy path, ветки if/when не тестируются.
Алгоритм:
test-branch-analyzer для source файлаПример:
// Source: PaymentInteractor.kt
fun processPayment(amount: Int): Result {
if (amount <= 0) return Result.Error("Invalid amount")
if (amount > MAX_AMOUNT) return Result.Error("Exceeds limit")
return paymentRepo.process(amount)
}
// Existing test covers only success
@Test
fun processPayment_validAmount_success()
// After --branches:
@Test
fun processPayment_zeroAmount_returnsInvalidAmountError()
@Test
fun processPayment_negativeAmount_returnsInvalidAmountError()
@Test
fun processPayment_exceedsMaxAmount_returnsExceedsLimitError()
Вывод:
🌳 Branch Coverage Fix Report
═══════════════════════════════════════════════════════
File: PaymentInteractorTest.kt
Added tests for uncovered branches:
✅ processPayment_zeroAmount_returnsInvalidAmountError
✅ processPayment_negativeAmount_returnsInvalidAmountError
✅ processPayment_exceedsMaxAmount_returnsExceedsLimitError
Branch coverage: 33% → 100% (+67%)
Проблема: Используются старые JUnit assertions вместо Truth.
Замены:
// ❌ BEFORE
assertTrue(result.isSuccess)
assertFalse(result.isEmpty)
assertEquals(expected, actual)
assertNotNull(result)
assertNull(result)
// ✅ AFTER
assertThat(result.isSuccess).isTrue()
assertThat(result.isEmpty).isFalse()
assertThat(actual).isEqualTo(expected)
assertThat(result).isNotNull()
assertThat(result).isNull()
Алгоритм:
import org.junit.Assert.*import com.google.common.truth.Truth.assertThatВывод:
✨ Assertions Fix Report
═══════════════════════════════════════════════════════
Module: core/domain
Fixed files:
✅ UserValidatorTest.kt - 12 assertions
✅ AmountFormatterTest.kt - 8 assertions
✅ DateUtilsTest.kt - 5 assertions
Total: 25 assertions migrated to Truth
Проблема: Тесты без @DisplayName — непонятно что тестируется.
Исправление:
// ❌ BEFORE
@Test
fun login_validCredentials_success() = runTest { ... }
// ✅ AFTER
@Test
@DisplayName("login с валидными credentials возвращает success")
fun login_validCredentials_success() = runTest { ... }
Алгоритм:
@DisplayNamelogin_validCredentials_success → "login с валидными credentials возвращает success"processPayment_negativeAmount_error → "processPayment с negative amount возвращает error"Вывод:
📝 Display Names Fix Report
═══════════════════════════════════════════════════════
Module: feature/auth
Added @DisplayName:
✅ AuthRepositoryTest.kt - 8 tests
✅ LoginInteractorTest.kt - 5 tests
⏭️ TokenValidatorTest.kt - already has DisplayNames
Total: 13 @DisplayName annotations added
Выполняет все исправления в порядке приоритета:
--flow-verify (critical - memory leaks)--branches (high - coverage)--assertions (medium - style)--display-names (low - readability)Вывод:
🔧 Full Test Fix Report
═══════════════════════════════════════════════════════
Module: feature/auth
1. Flow Verify: 4 memory leaks fixed
2. Branches: 12 tests added, coverage +23%
3. Assertions: 25 migrated to Truth
4. Display Names: 13 added
✅ All fixes applied!
Run tests to verify:
./gradlew :feature:auth:test
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub ivanlutsenko/awac-ai-agent-plugins