| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| Model | sonnet |
test-runner-agent โ ํ ์คํธ ์๋ ๊ฒ์ฌ๊ด#
ํ๋ง๋๋ก#
์ ๊ธฐ๋ฅ์ PR๋ก ์ฌ๋ฆฌ๊ธฐ ์ ์ "์ด๊ฑฐ ์ง์ง ์ ๋์๊ฐ๋?" ์๋์ผ๋ก ์ ๊ฒํด ์ฃผ๋ ํ์ง ๊ฒ์ฌ๊ด์ ๋๋ค. ๊ณต์ฅ์์ ์ ํ์ ์ถํํ๊ธฐ ์ ๋ง์ง๋ง ๊ฒ์๋๋ฅผ ํต๊ณผ์ํค๋ ๊ฒ๊ณผ ๊ฐ์์. ๊ฒ์๋ฅผ ํต๊ณผํ์ง ๋ชปํ๋ฉด ์ถํ(PR ์์ฑ)๋ฅผ ๋ง์ต๋๋ค.
๋๊ฐยท์ธ์ ์ฐ๋์#
- ์ ๊ธฐ๋ฅ ๊ฐ๋ฐ์ ๋ง์น๊ณ PR(์ฝ๋ ๋ณํฉ ์์ฒญ)์ ์ฌ๋ฆฌ๊ธฐ ์ง์ , ์๋ ๊ฐ๋ฐ ํ๋ฆ์ด ์ด ๊ฒ์ฌ๊ด์ ํธ์ถํฉ๋๋ค.
- ์ฌ๋์ด ์ง์ ๋ถ๋ฅด๊ธฐ๋ณด๋ค๋, ๊ธฐ๋ฅ ๊ฐ๋ฐ ํ์ดํ๋ผ์ธ์ด "๋ง์ง๋ง ํ์ง ๊ฒ์ดํธ"๋ก ์๋ ์คํํฉ๋๋ค.
- ํ ์คํธ ์ฝ๋๊ฐ ์์ ์์ผ๋ฉด, ๊ฒ์ฌ๊ด์ด ์์์ ํ ์คํธ ์์ฑ ์ ๋ฌธ ๋ด๋น์์๊ฒ ์ผ์ ๋๊ฒจ ๋จผ์ ๋ง๋ค๊ฒ ํฉ๋๋ค.
๋ฌด์์ ํด์ฃผ๋์#
- ์์ด์ผ ํ ํ ์คํธ๊ฐ ๋ค ์๋์ง ํ์ธ โ ์์ผ๋ฉด ์๋์ผ๋ก ๋ง๋ค๋๋ก ์์ํฉ๋๋ค.
- ์ฌ๋ฌ ์ข ๋ฅ์ ํ ์คํธ๋ฅผ ์ฐจ๋ก๋ก ์คํ โ ๊ธฐ๋ฅ ๋จ์ ํ ์คํธ, ํ๋ฉด ์ํ ํ ์คํธ, ์๋๋ฆฌ์ค ํ ์คํธ, ์๋ฒ(๋ฐฑ์๋) ํ ์คํธ๊น์ง.
- ์คํจํ ํ ์คํธ์ ์์ธ์ ๋ถ์ํ๊ณ , ๊ฐ๋จํ ๋ฌธ์ ๋ ์ค์ค๋ก ๊ณ ์ณ(์ต๋ 3๋ฒ) ๋ค์ ๋๋ฆฝ๋๋ค.
- ํฉ๊ฒฉ/๋ถํฉ๊ฒฉ ํ์ ๋ฆฌํฌํธ๋ฅผ ๋ณด๊ธฐ ์ข์ ํ ํํ๋ก ์ถ๋ ฅํฉ๋๋ค (๋ช ๊ฐ ํต๊ณผ/์คํจ, ์์ ์๊ฐ, ์ปค๋ฒ๋ฆฌ์ง ๋ฑ).
- ์ต์ข ํต๊ณผ ๊ฒ์ดํธ โ ๋ชจ๋ ํ์ ํ ์คํธ๊ฐ ํต๊ณผํด์ผ๋ง PR ์์ฑ์ ํ์ฉํ๊ณ , ํ๋๋ผ๋ ๋งํ๋ฉด PR์ ์ฐจ๋จํฉ๋๋ค.
์ด๋ป๊ฒ ์ฐ๋์#
# ํน์ ๊ธฐ๋ฅ๋ง ํ
์คํธ
melos exec --scope=feature_{feature_name} -- flutter test
# ์ปค๋ฒ๋ฆฌ์ง(ํ
์คํธ๊ฐ ์ฝ๋๋ฅผ ์ผ๋ง๋ ๋ฎ๋์ง)๊น์ง ํฌํจํด ํ
์คํธ
melos run test:with-html-coverage
# ํ
์คํธ ํ์ผ ํ๋๋ง ์ฝ ์ง์ด ์คํ
melos exec --scope=feature_{feature_name} -- \
flutter test test/domain/usecase/get_posts_usecase_test.dart
๊ฒ์ฌ๊ด์๊ฒ ๋๊ธธ ์ ์๋ ์ค์ ๊ฐ(ํ๋ผ๋ฏธํฐ):
feature_name(ํ์): ๊ฒ์ฌํ ๊ธฐ๋ฅ ์ด๋ฆtest_types: ์ด๋ค ํ ์คํธ๋ง ๋๋ฆด์ง ์ ํ (์ ์ฃผ๋ฉด ์ ๋ถ)auto_fix: ๊ฐ๋จํ ์คํจ ์๋ ์์ ์ฌ๋ถ (๊ธฐ๋ณธ ์ผ์ง)coverage: ์ปค๋ฒ๋ฆฌ์ง ๋ฆฌํฌํธ ์์ฑ ์ฌ๋ถ (๊ธฐ๋ณธ ๊บผ์ง)require_tests: ํ ์คํธ๊ฐ ์์ ๋ ์๋ ์์ฑ ์์ ์ฌ๋ถ (๊ธฐ๋ณธ ์ผ์ง)
์์์ ๋ฌด์จ ์ผ์ด ๋ฒ์ด์ง๋์#
- ๊ธฐ์กด ํ ์คํธ ๋จผ์ ์ ๊ฒ(๊ธฐ์ค์ ์ก๊ธฐ) โ ์ง๊ธ๊น์ง ์ ๋๋ ํ ์คํธ๋ค์ ๋จผ์ ๋๋ ค, ์ด๋ฒ ๋ณ๊ฒฝ์ด ๋ฉ์ฉกํ ๋ถ๋ถ์ ๋ง๊ฐ๋จ๋ฆฌ์ง ์์๋์ง ๋น๊ตํ ๊ธฐ์ค์ ๋ง๋ญ๋๋ค.
- ๋น ์ง ํ ์คํธ ์ฑ์ฐ๊ธฐ โ ์์ด์ผ ํ ํ ์คํธ๊ฐ ์์ผ๋ฉด ์ ๋ฌธ ๋ด๋น์์๊ฒ ์์ฑ์ ๋งก๊น๋๋ค. ํ ์คํธ๊ฐ ์์ผ๋ฉด PR์ ๋ง์ต๋๋ค.
- ํ ์คํธ ํ๊ฒฝ ์ค๋น โ ์ฝ๋ ์์ฑยท๋ถ์์ ๋ง์ณ ์คํ ๊ฐ๋ฅํ ์ํ๋ก ๋ง๋ญ๋๋ค.
- ์ฐจ๋ก๋๋ก ์คํ โ ๊ธฐ๋ฅ ๋จ์ โ ํ๋ฉด ์ํ โ (๋ณ๊ฒฝ์ด ์์ผ๋ฉด) ์๋ฒ โ ์๋๋ฆฌ์ค ์์ผ๋ก ๋๋ฆฝ๋๋ค.
- ์คํจ ๋ถ์ & ์๋ ์์ โ ๊ณ ์น ์ ์๋ ์คํจ๋ ์ค์ค๋ก ๊ณ ์ณ ์ต๋ 3๋ฒ๊น์ง ๋ค์ ๋๋ฆฝ๋๋ค.
- ์ต์ข ํฉ๊ฒฉ ํ์ โ ํ์ ํ ์คํธ๊ฐ ๋ชจ๋ ํต๊ณผํ๊ณ ๊ธฐ์กด ํต๊ณผ์จ์ด ๋จ์ด์ง์ง ์์์ผ ํฉ๊ฒฉ. ์คํจํ๋ฉด PR ์์ฑ์ ์ฐจ๋จํฉ๋๋ค.
โ๏ธ ์์ธ ์ต์ ยท์คํ ๋ช ์ธ (๊ฐ๋ฐ์ / AI ์์ด์ ํธ์ฉ)
Role and Responsibilities#
This agent verifies and runs tests for Features.
- Test Existence Check: Verify required test files exist
- Test Generation Delegation: Delegate to specialist agents when tests are missing
- Test Execution: Run Unit, BLoC, BDD Widget, and Backend integration tests
- Result Analysis: Analyze failed test causes
- Auto-Fix: Auto-fix simple test failures
- Verification Gate: Verify all tests pass (required gate before PR creation)
Input Parameters#
| Parameter | Required | Type | Description |
|---|---|---|---|
feature_name | โ | string | Feature module name |
test_types | โ | string[] | unit | bloc | bdd | backend_unit | backend_integration (default: all) |
auto_fix | โ | boolean | Auto-fix attempt flag (default: true) |
coverage | โ | boolean | Generate coverage flag (default: false) |
require_tests | โ | boolean | Delegate creation when tests missing (default: true) |
Output#
interface TestResult {
success: boolean;
summary: TestSummary;
failures: TestFailure[];
coverage?: CoverageReport;
backend_tests?: BackendTestResult;
fixed_tests: string[];
}
interface TestSummary {
total: number;
passed: number;
failed: number;
skipped: number;
duration: string;
}
interface TestFailure {
test_name: string;
file_path: string;
error_message: string;
stack_trace: string;
fixable: boolean;
}
interface CoverageReport {
line_coverage: number;
branch_coverage: number;
uncovered_files: string[];
}
interface BackendTestResult {
unit_tests: { endpoint: number; service: number; passed: number; failed: number };
integration_tests: { total: number; passed: number; failed: number };
}Test Execution by Type#
Unit Test (UseCase)#
# Run UseCase tests
melos exec --scope=feature_{feature_name} -- \
flutter test test/domain/usecase/ --reporter expandedTest Location: feature/{location}/{feature_name}/test/domain/usecase/
Test Targets:
get_{entity}s_usecase_test.dartget_{entity}_usecase_test.dartcreate_{entity}_usecase_test.dartupdate_{entity}_usecase_test.dartdelete_{entity}_usecase_test.dart
BLoC Test#
# Run BLoC tests
melos exec --scope=feature_{feature_name} -- \
flutter test test/presentation/bloc/ --reporter expandedTest Location: feature/{location}/{feature_name}/test/presentation/bloc/
Test Targets:
{feature}_list_bloc_test.dart{feature}_detail_bloc_test.dart{feature}_form_bloc_test.dart
BDD Widget Test#
# Run BDD Widget tests
melos exec --scope=feature_{feature_name} -- \
flutter test test/src/bdd/ --reporter expandedTest Location: feature/{location}/{feature_name}/test/src/bdd/
Test Targets:
{feature}_list.feature+ steps{feature}_detail.feature+ steps{feature}_form.feature+ steps
Execution Flow#
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 0: Existing Test Verification (Baseline) โ ๏ธ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ - Run all existing tests for related packages โ
โ - On failure โ fix implementation code or existing tests first โ
โ - Record baseline pass rate (for regression verification) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 0.5: Check Test Existence and Delegate Creation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [Frontend test check] โ
โ - UseCase test files exist? โ Call unit-test-agent if missing โ
โ - BLoC test files exist? โ Call bloc-test-agent if missing โ
โ - Widget test needed? โ Call widget-test-agent if missing โ
โ [Backend test check - on Backend changes] โ
โ - Endpoint tests exist? โ serverpod-test-agent if missing โ
โ - Service logic tests exist? โ serverpod-test-agent if missing โ
โ - Integration tests exist? โ Call serverpod-test-agent if missing โ
โ โ ๏ธ PR creation blocked if tests are not written โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 1: Prepare Test Environment โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ $ melos run build โ
โ - Verify code generation complete โ
โ - Verify no analysis errors โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 2: Run Unit Tests โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ $ melos exec --scope=feature_{name} -- โ
โ flutter test test/domain/usecase/ โ
โ - Verify UseCase logic โ
โ - Verify Mock setup โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 3: Run BLoC Tests โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ $ melos exec --scope=feature_{name} -- โ
โ flutter test test/presentation/bloc/ โ
โ - Verify State transitions โ
โ - Verify Event handling โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 3.5: Run Backend Tests (on Backend changes) โ ๏ธ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [Unit tests] โ
โ $ melos exec --scope=kobic_server -- โ
โ dart test test/unit/{feature}/ โ
โ - Verify endpoint logic โ
โ - Verify service business logic โ
โ [Integration tests] โ
โ $ melos exec --scope=kobic_server -- โ
โ dart test test/integration/{feature}/ โ
โ - withServerpod-based E2E verification โ
โ - Auth/permission verification โ
โ - CRUD flow verification โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 4: Run BDD Widget Tests โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ $ melos exec --scope=feature_{name} -- โ
โ flutter test test/src/bdd/ โ
โ - Run Gherkin scenarios โ
โ - Verify UI interactions โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 5: Result Analysis and Auto-Fix โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ IF failed tests exist: โ
โ - Analyze failure cause โ
โ - Determine if auto-fix is possible โ
โ - Attempt auto-fix (up to 3 times) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 6: Verification Gate (required before PR) โ ๏ธ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ - Frontend: UseCase test โฅ 1 passed โ
โ - Frontend: BLoC test โฅ 1 passed โ
โ - (On Backend changes) Backend unit tests passed โ
โ - (On Backend changes) Backend integration tests passed โ
โ - Regression check: Existing test pass rate โฅ baseline โ
โ โ ๏ธ PR creation blocked on gate failure โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโBackend Test (Endpoint/Service)#
Unit Tests
# Run endpoint/service unit tests
melos exec --scope=kobic_server -- \
dart test test/unit/{feature_name}/ --reporter expandedTest Location: backend/kobic_server/test/unit/{feature_name}/
Test Targets:
{feature}_endpoint_test.dart(endpoint unit tests){feature}_service_test.dart(service logic unit tests)
Integration Tests
# Run withServerpod integration tests
melos exec --scope=kobic_server -- \
dart test test/integration/{feature_name}/ --reporter expandedTest Location: backend/kobic_server/test/integration/{feature_name}/
Test Targets:
{feature}_integration_test.dart
Verification Items:
- Auth-required endpoints:
ServerpodUnauthenticatedExceptionverification - Permission checks:
ServerpodInsufficientAccessExceptionverification - CRUD flow: Create โ Read โ Update โ Delete scenarios
- Error cases:
NotFoundException,ValidationExceptionverification
Auto-Fix Patterns#
Fixable Failure Types#
| Failure Type | Cause | Auto-Fix Method |
|---|---|---|
| Missing Mock | No when() setup | Add Mock setup |
| State mismatch | Expected State differs from actual | Update State values |
| Widget not found | Wrong Key/Finder | Fix Finder |
| Missing import | Required import missing | Add import |
| Timeout | Async processing delay | Adjust pumpAndSettle |
Non-Fixable Failure Types#
| Failure Type | Reason |
|---|---|
| Logic error | Requires business logic judgment |
| Architecture issue | Requires design changes |
| External dependency | External service issue |
Auto-Fix Flow#
1. Parse failure message
โ
2. Classify failure type
โ
3. Determine if fixable
โ
4. Generate fix code
โ
5. Apply fix
โ
6. Re-run test
โ
7. Verify success/failureMelos Script Usage#
Single Feature Test#
# Test specific Feature only
melos exec --scope=feature_{feature_name} -- flutter test
# Or
melos run test --scope=feature_{feature_name}Test with Coverage#
# Test with coverage
melos run test:with-html-coverageRun Specific Test File#
# Single file test
melos exec --scope=feature_{feature_name} -- \
flutter test test/domain/usecase/get_posts_usecase_test.dartResult Report#
Console Output Format#
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Test Results: feature_community โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ Unit Tests (UseCase): โ
โ โ
GetPostsUseCase: 5 passed โ
โ โ
GetPostUseCase: 3 passed โ
โ โ
CreatePostUseCase: 4 passed โ
โ โ
โ BLoC Tests: โ
โ โ
PostListBloc: 8 passed โ
โ โ
PostDetailBloc: 6 passed โ
โ โ PostFormBloc: 4 passed, 1 failed โ
โ โ
โ BDD Widget Tests: โ
โ โ
community_list.feature: 7 scenarios passed โ
โ โ
community_detail.feature: 5 scenarios passed โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ Summary: 42/43 passed (97.7%) โ
โ Duration: 45.3s โ
โ Coverage: 85.2% (lines) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโFailure Detail Report#
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Failed Test Details โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ File: post_form_bloc_test.dart โ
โ Test: should emit error state when validation fails โ
โ โ
โ Error: โ
โ Expected: PostFormError(message: " Title required " ) โ
โ Actual: PostFormError(message: " ์ ๋ชฉ์ ์
๋ ฅํ์ธ์ " ) โ
โ โ
โ Fixable: โ
Yes (message mismatch) โ
โ Auto-fix: Applied โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโError Handling#
On Build Failure#
1. Check analysis errors
2. Re-run code generation
3. If still failing โ report failureTest Timeout#
1. Individual test timeout: 30 seconds
2. Overall test timeout: 10 minutes
3. On timeout โ skip that test and continueKey Rules#
- Build First: Verify build success before tests
- Follow Order: Execute in Unit โ BLoC โ BDD order
- Auto-Fix Limit: Attempt up to 3 times only
- Failure Tolerance: Skip and report on non-fixable failures
- Coverage Target: Minimum 80% line coverage
- Detailed Logs: Provide detailed information for all failures