@sk8metal/michi-cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -847
- package/dist/scripts/phase-runner.js +1 -1
- package/dist/scripts/phase-runner.js.map +1 -1
- package/dist/scripts/utils/multi-repo-validator.d.ts +18 -0
- package/dist/scripts/utils/multi-repo-validator.d.ts.map +1 -1
- package/dist/scripts/utils/multi-repo-validator.js +42 -0
- package/dist/scripts/utils/multi-repo-validator.js.map +1 -1
- package/dist/scripts/utils/tasks-format-validator.js +3 -3
- package/dist/scripts/utils/tasks-format-validator.js.map +1 -1
- package/docs/README.md +20 -83
- package/docs/getting-started/configuration.md +379 -0
- package/docs/getting-started/installation.md +59 -0
- package/docs/getting-started/quick-start.md +76 -0
- package/docs/guides/ai-tools.md +311 -0
- package/docs/guides/atlassian-integration.md +116 -0
- package/docs/guides/claude-code.md +155 -0
- package/docs/guides/multi-repo.md +117 -0
- package/docs/guides/workflow.md +382 -0
- package/docs/reference/ai-commands.md +92 -0
- package/docs/reference/cli.md +756 -0
- package/docs/reference/environment-variables.md +192 -0
- package/docs/troubleshooting.md +543 -0
- package/package.json +1 -1
- package/scripts/phase-runner.ts +1 -1
- package/scripts/utils/__tests__/multi-repo-validator.test.ts +159 -1
- package/scripts/utils/multi-repo-validator.ts +50 -0
- package/scripts/utils/tasks-format-validator.ts +3 -3
- package/templates/claude/agents/e2e-first-planner/AGENT.md +1 -1
- package/templates/claude/agents/pr-resolver/AGENT.md +15 -3
- package/templates/claude/commands/michi/e2e-plan.md +1 -1
- package/templates/claude/commands/michi/spec-design.md +2 -2
- package/templates/claude/commands/michi/spec-tasks.md +156 -0
- package/templates/claude/commands/michi/test-planning.md +1 -1
- package/templates/claude/commands/michi/validate-design.md +3 -3
- package/templates/claude/commands/michi-multi-repo/impl-all.md +30 -1
- package/templates/claude/commands/michi-multi-repo/propagate-specs.md +14 -1
- package/templates/claude/commands/michi-multi-repo/spec-review.md +16 -2
- package/templates/claude-agent/agents/repo-spec-executor.md +1 -1
- package/templates/claude-agent/commands/michi/spec-tasks.md +117 -0
- package/templates/claude-agent/rules/code-size-monitor.md +26 -0
- package/templates/claude-agent/rules/code-size-rules.md +32 -0
- package/templates/codex/AGENTS.override.md +1 -1
- package/templates/codex/rules/README.md +2 -2
- package/templates/cursor/commands/michi/spec-tasks.md +117 -0
- package/templates/michi/cc-sdd-overrides/settings/rules/design-review-michi.md +1 -1
- package/docs/context.md +0 -59
- package/docs/michi-development/contributing/development.md +0 -341
- package/docs/michi-development/contributing/release.md +0 -365
- package/docs/michi-development/design/config-unification.md +0 -733
- package/docs/michi-development/design/design-config-current-state.md +0 -330
- package/docs/michi-development/design/design-config-implementation.md +0 -628
- package/docs/michi-development/design/design-config-migration.md +0 -952
- package/docs/michi-development/design/design-config-security.md +0 -771
- package/docs/michi-development/design/design-config-solution.md +0 -583
- package/docs/michi-development/design/design-config-testing.md +0 -892
- package/docs/michi-development/testing/manual-verification-flow.md +0 -871
- package/docs/michi-development/testing/manual-verification-other-tools.md +0 -1279
- package/docs/michi-development/testing/manual-verification-troubleshooting.md +0 -122
- package/docs/michi-development/testing/pre-publish-checklist.md +0 -560
- package/docs/michi-development/testing-strategy.md +0 -87
- package/docs/plan.md +0 -275
- package/docs/user-guide/getting-started/github-token-setup.md +0 -510
- package/docs/user-guide/getting-started/new-repository-setup.md +0 -704
- package/docs/user-guide/getting-started/quick-start.md +0 -212
- package/docs/user-guide/getting-started/setup.md +0 -819
- package/docs/user-guide/guides/agent-skills-integration.md +0 -222
- package/docs/user-guide/guides/customization.md +0 -537
- package/docs/user-guide/guides/internationalization.md +0 -540
- package/docs/user-guide/guides/migration-guide.md +0 -138
- package/docs/user-guide/guides/multi-project.md +0 -368
- package/docs/user-guide/guides/multi-repo-guide.md +0 -1590
- package/docs/user-guide/guides/phase-automation.md +0 -419
- package/docs/user-guide/guides/workflow.md +0 -574
- package/docs/user-guide/hands-on/README.md +0 -142
- package/docs/user-guide/hands-on/claude-agent-setup.md +0 -597
- package/docs/user-guide/hands-on/claude-setup.md +0 -452
- package/docs/user-guide/hands-on/cursor-setup.md +0 -353
- package/docs/user-guide/hands-on/troubleshooting.md +0 -964
- package/docs/user-guide/hands-on/verification-checklist.md +0 -439
- package/docs/user-guide/hands-on/workflow-walkthrough.md +0 -1078
- package/docs/user-guide/reference/config.md +0 -589
- package/docs/user-guide/reference/multi-repo-api.md +0 -771
- package/docs/user-guide/reference/quick-reference.md +0 -297
- package/docs/user-guide/reference/security-test-payloads.md +0 -50
- package/docs/user-guide/reference/tasks-template.md +0 -550
- package/docs/user-guide/release/ci-setup-java.md +0 -114
- package/docs/user-guide/release/ci-setup-nodejs.md +0 -94
- package/docs/user-guide/release/ci-setup-php.md +0 -102
- package/docs/user-guide/release/ci-setup-troubleshooting.md +0 -94
- package/docs/user-guide/release/ci-setup.md +0 -188
- package/docs/user-guide/release/release-flow.md +0 -476
- package/docs/user-guide/templates/test-specs/README.md +0 -173
- package/docs/user-guide/templates/test-specs/e2e-test-spec-template.md +0 -553
- package/docs/user-guide/templates/test-specs/integration-test-spec-template.md +0 -435
- package/docs/user-guide/templates/test-specs/performance-test-spec-template.md +0 -454
- package/docs/user-guide/templates/test-specs/security-test-spec-template.md +0 -625
- package/docs/user-guide/templates/test-specs/unit-test-spec-template.md +0 -328
- package/docs/user-guide/testing/integration-tests.md +0 -312
- package/docs/user-guide/testing/tdd-cycle.md +0 -349
- package/docs/user-guide/testing/test-execution-flow.md +0 -396
- package/docs/user-guide/testing/test-failure-handling.md +0 -521
- package/docs/user-guide/testing/test-planning-flow.md +0 -185
- package/docs/user-guide/testing-strategy.md +0 -185
- package/docs/verification-guide.md +0 -518
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
# Unit Test Specification: {{TEST_NAME}}
|
|
2
|
-
|
|
3
|
-
**Author**: {{AUTHOR}}
|
|
4
|
-
**Date**: {{DATE}}
|
|
5
|
-
**Version**: 1.0
|
|
6
|
-
|
|
7
|
-
## 1. Overview
|
|
8
|
-
|
|
9
|
-
### 1.1 Purpose
|
|
10
|
-
{{PURPOSE}}
|
|
11
|
-
|
|
12
|
-
Example: To verify that individual functions and classes in the {{MODULE_NAME}} module work correctly in isolation.
|
|
13
|
-
|
|
14
|
-
### 1.2 Scope
|
|
15
|
-
{{SCOPE}}
|
|
16
|
-
|
|
17
|
-
Example: This test specification covers all public methods of the {{CLASS_NAME}} class and their edge cases.
|
|
18
|
-
|
|
19
|
-
### 1.3 Testing Tool
|
|
20
|
-
- **Tool**: {{TOOL_NAME}}
|
|
21
|
-
- **Version**: {{VERSION}}
|
|
22
|
-
|
|
23
|
-
Example:
|
|
24
|
-
- **Tool**: Vitest (Node.js) / JUnit 5 (Java) / PHPUnit (PHP)
|
|
25
|
-
- **Version**: 1.0.0 / 5.10.0 / 10.5.0
|
|
26
|
-
|
|
27
|
-
## 2. Test Environment
|
|
28
|
-
|
|
29
|
-
### 2.1 Software Requirements
|
|
30
|
-
- Programming Language: {{LANGUAGE}} {{LANGUAGE_VERSION}}
|
|
31
|
-
- Testing Framework: {{FRAMEWORK}} {{FRAMEWORK_VERSION}}
|
|
32
|
-
- Mocking Library: {{MOCKING_LIBRARY}} (if applicable)
|
|
33
|
-
- Dependencies: {{DEPENDENCIES}}
|
|
34
|
-
|
|
35
|
-
### 2.2 Hardware Requirements
|
|
36
|
-
- Not applicable for unit tests (runs on developer's machine or CI/CD)
|
|
37
|
-
|
|
38
|
-
### 2.3 Test Data
|
|
39
|
-
- Mock data location: `{{MOCK_DATA_PATH}}`
|
|
40
|
-
- Test fixtures: `{{FIXTURES_PATH}}`
|
|
41
|
-
- Data setup: {{DATA_SETUP_DESCRIPTION}}
|
|
42
|
-
|
|
43
|
-
## 3. Functions/Classes to Test
|
|
44
|
-
|
|
45
|
-
### 3.1 Target Components
|
|
46
|
-
List all functions/classes to be tested:
|
|
47
|
-
|
|
48
|
-
| Component | Type | Description | Priority |
|
|
49
|
-
|-----------|------|-------------|----------|
|
|
50
|
-
| {{COMPONENT_1}} | Function/Class | {{DESCRIPTION_1}} | High/Medium/Low |
|
|
51
|
-
| {{COMPONENT_2}} | Function/Class | {{DESCRIPTION_2}} | High/Medium/Low |
|
|
52
|
-
|
|
53
|
-
### 3.2 Mocking Strategy
|
|
54
|
-
Describe what external dependencies will be mocked:
|
|
55
|
-
|
|
56
|
-
| Dependency | Mock Type | Reason |
|
|
57
|
-
|------------|-----------|--------|
|
|
58
|
-
| {{DEPENDENCY_1}} | {{MOCK_TYPE}} | {{REASON}} |
|
|
59
|
-
| {{DEPENDENCY_2}} | {{MOCK_TYPE}} | {{REASON}} |
|
|
60
|
-
|
|
61
|
-
Example:
|
|
62
|
-
| Dependency | Mock Type | Reason |
|
|
63
|
-
|------------|-----------|--------|
|
|
64
|
-
| Database | Mock object | Avoid external I/O, ensure test isolation |
|
|
65
|
-
| HTTP API | Stub | Control response for predictable testing |
|
|
66
|
-
|
|
67
|
-
## 4. Test Cases
|
|
68
|
-
|
|
69
|
-
### Test Case UT-001: {{TEST_CASE_NAME}}
|
|
70
|
-
|
|
71
|
-
**Description**: {{TEST_CASE_DESCRIPTION}}
|
|
72
|
-
|
|
73
|
-
Example: Verify that `calculateTotal()` returns the correct sum when given an array of positive numbers.
|
|
74
|
-
|
|
75
|
-
**Preconditions**:
|
|
76
|
-
- {{PRECONDITION_1}}
|
|
77
|
-
- {{PRECONDITION_2}}
|
|
78
|
-
|
|
79
|
-
Example:
|
|
80
|
-
- Input array is not null
|
|
81
|
-
- All array elements are valid numbers
|
|
82
|
-
|
|
83
|
-
**Test Steps**:
|
|
84
|
-
1. {{STEP_1}}
|
|
85
|
-
2. {{STEP_2}}
|
|
86
|
-
3. {{STEP_3}}
|
|
87
|
-
|
|
88
|
-
Example:
|
|
89
|
-
1. Create an input array: `[10, 20, 30]`
|
|
90
|
-
2. Call `calculateTotal(input)`
|
|
91
|
-
3. Assert that the result equals `60`
|
|
92
|
-
|
|
93
|
-
**Expected Results**:
|
|
94
|
-
{{EXPECTED_RESULTS}}
|
|
95
|
-
|
|
96
|
-
Example:
|
|
97
|
-
- Function returns `60`
|
|
98
|
-
- No exceptions are thrown
|
|
99
|
-
|
|
100
|
-
**Actual Results**:
|
|
101
|
-
[To be filled during test execution]
|
|
102
|
-
|
|
103
|
-
**Status**: [ ] Pass / [ ] Fail / [ ] Blocked
|
|
104
|
-
|
|
105
|
-
**Notes**:
|
|
106
|
-
{{NOTES}}
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
### Test Case UT-002: {{TEST_CASE_NAME}}
|
|
111
|
-
|
|
112
|
-
**Description**: {{TEST_CASE_DESCRIPTION}}
|
|
113
|
-
|
|
114
|
-
**Preconditions**:
|
|
115
|
-
- {{PRECONDITION_1}}
|
|
116
|
-
- {{PRECONDITION_2}}
|
|
117
|
-
|
|
118
|
-
**Test Steps**:
|
|
119
|
-
1. {{STEP_1}}
|
|
120
|
-
2. {{STEP_2}}
|
|
121
|
-
3. {{STEP_3}}
|
|
122
|
-
|
|
123
|
-
**Expected Results**:
|
|
124
|
-
{{EXPECTED_RESULTS}}
|
|
125
|
-
|
|
126
|
-
**Actual Results**:
|
|
127
|
-
[To be filled during test execution]
|
|
128
|
-
|
|
129
|
-
**Status**: [ ] Pass / [ ] Fail / [ ] Blocked
|
|
130
|
-
|
|
131
|
-
**Notes**:
|
|
132
|
-
{{NOTES}}
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
### Test Case UT-003: Edge Case - {{EDGE_CASE_NAME}}
|
|
137
|
-
|
|
138
|
-
**Description**: {{EDGE_CASE_DESCRIPTION}}
|
|
139
|
-
|
|
140
|
-
Example: Verify that `calculateTotal()` handles empty array correctly.
|
|
141
|
-
|
|
142
|
-
**Preconditions**:
|
|
143
|
-
- {{PRECONDITION}}
|
|
144
|
-
|
|
145
|
-
**Test Steps**:
|
|
146
|
-
1. {{STEP_1}}
|
|
147
|
-
2. {{STEP_2}}
|
|
148
|
-
|
|
149
|
-
Example:
|
|
150
|
-
1. Create an empty array: `[]`
|
|
151
|
-
2. Call `calculateTotal([])`
|
|
152
|
-
3. Assert that the result equals `0`
|
|
153
|
-
|
|
154
|
-
**Expected Results**:
|
|
155
|
-
{{EXPECTED_RESULTS}}
|
|
156
|
-
|
|
157
|
-
**Actual Results**:
|
|
158
|
-
[To be filled during test execution]
|
|
159
|
-
|
|
160
|
-
**Status**: [ ] Pass / [ ] Fail / [ ] Blocked
|
|
161
|
-
|
|
162
|
-
**Notes**:
|
|
163
|
-
{{NOTES}}
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
### Test Case UT-004: Error Case - {{ERROR_CASE_NAME}}
|
|
168
|
-
|
|
169
|
-
**Description**: {{ERROR_CASE_DESCRIPTION}}
|
|
170
|
-
|
|
171
|
-
Example: Verify that `calculateTotal()` throws an appropriate error when given invalid input.
|
|
172
|
-
|
|
173
|
-
**Preconditions**:
|
|
174
|
-
- {{PRECONDITION}}
|
|
175
|
-
|
|
176
|
-
**Test Steps**:
|
|
177
|
-
1. {{STEP_1}}
|
|
178
|
-
2. {{STEP_2}}
|
|
179
|
-
|
|
180
|
-
Example:
|
|
181
|
-
1. Create an array with non-numeric value: `[10, 'invalid', 30]`
|
|
182
|
-
2. Call `calculateTotal(input)`
|
|
183
|
-
3. Assert that a `TypeError` is thrown
|
|
184
|
-
|
|
185
|
-
**Expected Results**:
|
|
186
|
-
{{EXPECTED_RESULTS}}
|
|
187
|
-
|
|
188
|
-
**Actual Results**:
|
|
189
|
-
[To be filled during test execution]
|
|
190
|
-
|
|
191
|
-
**Status**: [ ] Pass / [ ] Fail / [ ] Blocked
|
|
192
|
-
|
|
193
|
-
**Notes**:
|
|
194
|
-
{{NOTES}}
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## 5. Test Coverage
|
|
199
|
-
|
|
200
|
-
### 5.1 Coverage Goals
|
|
201
|
-
- **Target Coverage**: {{TARGET_COVERAGE}}%
|
|
202
|
-
- **Minimum Acceptable Coverage**: {{MIN_COVERAGE}}%
|
|
203
|
-
|
|
204
|
-
Example:
|
|
205
|
-
- **Target Coverage**: 95%
|
|
206
|
-
- **Minimum Acceptable Coverage**: 80%
|
|
207
|
-
|
|
208
|
-
### 5.2 Coverage Report Location
|
|
209
|
-
- Report Path: `{{COVERAGE_REPORT_PATH}}`
|
|
210
|
-
- HTML Report: `{{HTML_REPORT_PATH}}`
|
|
211
|
-
|
|
212
|
-
Example:
|
|
213
|
-
- Report Path: `coverage/lcov.info`
|
|
214
|
-
- HTML Report: `coverage/index.html`
|
|
215
|
-
|
|
216
|
-
## 6. Test Execution Summary
|
|
217
|
-
|
|
218
|
-
| ID | Test Name | Status | Executed By | Date | Notes |
|
|
219
|
-
|----|-----------|--------|-------------|------|-------|
|
|
220
|
-
| UT-001 | {{NAME}} | | | | |
|
|
221
|
-
| UT-002 | {{NAME}} | | | | |
|
|
222
|
-
| UT-003 | {{NAME}} | | | | |
|
|
223
|
-
| UT-004 | {{NAME}} | | | | |
|
|
224
|
-
|
|
225
|
-
## 7. Defects Found
|
|
226
|
-
|
|
227
|
-
| Defect ID | Severity | Description | Status |
|
|
228
|
-
|-----------|----------|-------------|--------|
|
|
229
|
-
| | High/Medium/Low | | Open/In Progress/Fixed/Closed |
|
|
230
|
-
|
|
231
|
-
## 8. Sign-off
|
|
232
|
-
|
|
233
|
-
**Tested By**: _______________
|
|
234
|
-
**Date**: _______________
|
|
235
|
-
**Approved By**: _______________
|
|
236
|
-
**Date**: _______________
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## Appendix A: Code Examples
|
|
241
|
-
|
|
242
|
-
### Example Test Code (Node.js/Vitest)
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
246
|
-
import { calculateTotal } from './calculator';
|
|
247
|
-
|
|
248
|
-
describe('calculateTotal', () => {
|
|
249
|
-
it('should return correct sum for positive numbers', () => {
|
|
250
|
-
const input = [10, 20, 30];
|
|
251
|
-
const result = calculateTotal(input);
|
|
252
|
-
expect(result).toBe(60);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should handle empty array', () => {
|
|
256
|
-
const result = calculateTotal([]);
|
|
257
|
-
expect(result).toBe(0);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('should throw error for invalid input', () => {
|
|
261
|
-
expect(() => calculateTotal([10, 'invalid', 30])).toThrow(TypeError);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Example Test Code (Java/JUnit 5)
|
|
267
|
-
|
|
268
|
-
```java
|
|
269
|
-
import org.junit.jupiter.api.Test;
|
|
270
|
-
import static org.junit.jupiter.api.Assertions.*;
|
|
271
|
-
|
|
272
|
-
class CalculatorTest {
|
|
273
|
-
@Test
|
|
274
|
-
void shouldReturnCorrectSumForPositiveNumbers() {
|
|
275
|
-
Calculator calc = new Calculator();
|
|
276
|
-
int[] input = {10, 20, 30};
|
|
277
|
-
int result = calc.calculateTotal(input);
|
|
278
|
-
assertEquals(60, result);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
@Test
|
|
282
|
-
void shouldHandleEmptyArray() {
|
|
283
|
-
Calculator calc = new Calculator();
|
|
284
|
-
int[] input = {};
|
|
285
|
-
int result = calc.calculateTotal(input);
|
|
286
|
-
assertEquals(0, result);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Example Test Code (PHP/PHPUnit)
|
|
292
|
-
|
|
293
|
-
```php
|
|
294
|
-
<?php
|
|
295
|
-
use PHPUnit\Framework\TestCase;
|
|
296
|
-
|
|
297
|
-
class CalculatorTest extends TestCase
|
|
298
|
-
{
|
|
299
|
-
public function testShouldReturnCorrectSumForPositiveNumbers()
|
|
300
|
-
{
|
|
301
|
-
$calculator = new Calculator();
|
|
302
|
-
$input = [10, 20, 30];
|
|
303
|
-
$result = $calculator->calculateTotal($input);
|
|
304
|
-
$this->assertEquals(60, $result);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public function testShouldHandleEmptyArray()
|
|
308
|
-
{
|
|
309
|
-
$calculator = new Calculator();
|
|
310
|
-
$input = [];
|
|
311
|
-
$result = $calculator->calculateTotal($input);
|
|
312
|
-
$this->assertEquals(0, $result);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
## Appendix B: TDD Principles
|
|
318
|
-
|
|
319
|
-
### RED-GREEN-REFACTOR Cycle
|
|
320
|
-
1. **RED**: Write a failing test first
|
|
321
|
-
2. **GREEN**: Write minimum code to pass the test
|
|
322
|
-
3. **REFACTOR**: Improve code while keeping tests green
|
|
323
|
-
|
|
324
|
-
### Important Rule
|
|
325
|
-
**Tests represent specifications. Do NOT modify tests to match implementation.**
|
|
326
|
-
|
|
327
|
-
- ❌ NG: Implementation doesn't match test, so modify the test
|
|
328
|
-
- ✅ OK: Specification changed, so update the test accordingly
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
# 統合テストガイド
|
|
2
|
-
|
|
3
|
-
## 概要
|
|
4
|
-
|
|
5
|
-
Michiプロジェクトの統合テストは、`setup-existing`コマンドの動作を検証するために作成されています。
|
|
6
|
-
|
|
7
|
-
## テスト構造
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
src/__tests__/integration/setup/
|
|
11
|
-
├── helpers/
|
|
12
|
-
│ ├── test-project.ts # テストプロジェクト作成ヘルパー
|
|
13
|
-
│ └── fs-assertions.ts # ファイルシステムアサーション
|
|
14
|
-
├── cursor.test.ts # Cursor環境テスト
|
|
15
|
-
├── claude.test.ts # Claude環境テスト
|
|
16
|
-
├── claude-agent.test.ts # Claude Agent環境テスト
|
|
17
|
-
└── validation.test.ts # 引数バリデーションテスト
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## テストケース
|
|
21
|
-
|
|
22
|
-
### 1. 環境別テスト
|
|
23
|
-
|
|
24
|
-
#### Cursor環境 (`cursor.test.ts`)
|
|
25
|
-
|
|
26
|
-
- ✅ `.cursor/rules/` ディレクトリ作成
|
|
27
|
-
- ✅ `.cursor/commands/` ディレクトリ作成
|
|
28
|
-
- ✅ `.kiro/` ディレクトリ構造作成
|
|
29
|
-
- ✅ `project.json` 作成とメタデータ検証
|
|
30
|
-
- ✅ `.env` テンプレート作成
|
|
31
|
-
- ✅ テンプレートレンダリング
|
|
32
|
-
- ✅ 言語サポート(ja, en)
|
|
33
|
-
- ✅ Git統合(リモートURL検出)
|
|
34
|
-
- ✅ エラーハンドリング
|
|
35
|
-
|
|
36
|
-
#### Claude環境 (`claude.test.ts`)
|
|
37
|
-
|
|
38
|
-
- ✅ `.claude/rules/` ディレクトリ作成
|
|
39
|
-
- ✅ `.kiro/` ディレクトリ構造作成
|
|
40
|
-
- ✅ `project.json` 作成
|
|
41
|
-
- ✅ `.env` テンプレート作成
|
|
42
|
-
- ✅ Cursor固有ディレクトリが作成されないことを確認
|
|
43
|
-
- ✅ 言語サポート
|
|
44
|
-
|
|
45
|
-
#### Claude Agent環境 (`claude-agent.test.ts`)
|
|
46
|
-
|
|
47
|
-
- ✅ `.claude/agents/` ディレクトリ作成
|
|
48
|
-
- ✅ `.kiro/` ディレクトリ構造作成
|
|
49
|
-
- ✅ `project.json` 作成
|
|
50
|
-
- ✅ `.env` テンプレート作成
|
|
51
|
-
- ✅ 他の環境固有ディレクトリが作成されないことを確認
|
|
52
|
-
- ✅ 言語サポート(ja, en, zh-TW)
|
|
53
|
-
|
|
54
|
-
### 2. バリデーションテスト (`validation.test.ts`)
|
|
55
|
-
|
|
56
|
-
#### 環境選択
|
|
57
|
-
|
|
58
|
-
- ✅ デフォルト環境(cursor)
|
|
59
|
-
- ✅ `--cursor` フラグ
|
|
60
|
-
- ✅ `--claude` フラグ
|
|
61
|
-
- ✅ `--claude-agent` フラグ
|
|
62
|
-
|
|
63
|
-
#### 言語バリデーション
|
|
64
|
-
|
|
65
|
-
- ✅ サポート言語: `ja`, `en`, `zh-TW`
|
|
66
|
-
- ✅ 非サポート言語でエラー
|
|
67
|
-
|
|
68
|
-
#### プロジェクト名バリデーション
|
|
69
|
-
|
|
70
|
-
**正常系:**
|
|
71
|
-
|
|
72
|
-
- ✅ 有効なプロジェクト名
|
|
73
|
-
- ✅ 日本語文字を含むプロジェクト名
|
|
74
|
-
- ✅ 前後の空白はトリム
|
|
75
|
-
|
|
76
|
-
**異常系:**
|
|
77
|
-
|
|
78
|
-
- ❌ 空文字列
|
|
79
|
-
- ❌ パストラバーサル文字 (`/`, `\`, `..`)
|
|
80
|
-
- ❌ 制御文字
|
|
81
|
-
- ❌ 100文字超
|
|
82
|
-
|
|
83
|
-
#### JIRAキーバリデーション
|
|
84
|
-
|
|
85
|
-
**正常系:**
|
|
86
|
-
|
|
87
|
-
- ✅ 2-10文字の大文字英字
|
|
88
|
-
- ✅ 小文字は自動的に大文字に変換
|
|
89
|
-
|
|
90
|
-
**異常系:**
|
|
91
|
-
|
|
92
|
-
- ❌ 1文字以下
|
|
93
|
-
- ❌ 11文字以上
|
|
94
|
-
- ❌ 数字を含む
|
|
95
|
-
- ❌ 特殊文字を含む
|
|
96
|
-
|
|
97
|
-
#### Gitリポジトリバリデーション
|
|
98
|
-
|
|
99
|
-
- ❌ `.git` ディレクトリがない場合エラー
|
|
100
|
-
|
|
101
|
-
## テスト実行方法
|
|
102
|
-
|
|
103
|
-
### すべてのテスト実行
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npm test
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### 統合テストのみ実行
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
npm run test:integration:setup
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### カバレッジ付き実行
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
npm run test:coverage:setup
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 監視モード
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
npm test -- --watch
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### UI モード
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
npm run test:ui
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## CI/CD
|
|
134
|
-
|
|
135
|
-
GitHub Actionsワークフローが `.github/workflows/test-setup.yml` に定義されています。
|
|
136
|
-
|
|
137
|
-
**実行タイミング:**
|
|
138
|
-
|
|
139
|
-
- `main`, `develop`, `feature/**` ブランチへのプッシュ
|
|
140
|
-
- `main`, `develop` ブランチへのプルリクエスト
|
|
141
|
-
|
|
142
|
-
**マトリクス戦略:**
|
|
143
|
-
|
|
144
|
-
- Node.js 18.x
|
|
145
|
-
- Node.js 20.x
|
|
146
|
-
|
|
147
|
-
**ステップ:**
|
|
148
|
-
|
|
149
|
-
1. コードチェックアウト
|
|
150
|
-
2. Node.js セットアップ
|
|
151
|
-
3. 依存関係インストール
|
|
152
|
-
4. 統合テスト実行
|
|
153
|
-
5. カバレッジ生成
|
|
154
|
-
6. カバレッジアップロード(Codecov)
|
|
155
|
-
7. Lint実行
|
|
156
|
-
8. TypeScript型チェック
|
|
157
|
-
|
|
158
|
-
## トラブルシューティング
|
|
159
|
-
|
|
160
|
-
### テストが失敗する場合
|
|
161
|
-
|
|
162
|
-
**症状:** テストプロジェクトの作成に失敗
|
|
163
|
-
|
|
164
|
-
**原因:** 一時ディレクトリの権限問題
|
|
165
|
-
|
|
166
|
-
**解決策:**
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
# 一時ディレクトリの権限を確認
|
|
170
|
-
ls -la /tmp
|
|
171
|
-
|
|
172
|
-
# 手動でクリーンアップ
|
|
173
|
-
rm -rf /tmp/test-project-*
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
**症状:** Git初期化エラー
|
|
179
|
-
|
|
180
|
-
**原因:** Gitがインストールされていない
|
|
181
|
-
|
|
182
|
-
**解決策:**
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
# Gitインストール確認
|
|
186
|
-
git --version
|
|
187
|
-
|
|
188
|
-
# macOS
|
|
189
|
-
brew install git
|
|
190
|
-
|
|
191
|
-
# Ubuntu
|
|
192
|
-
sudo apt-get install git
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
**症状:** TypeScriptコンパイルエラー
|
|
198
|
-
|
|
199
|
-
**原因:** 型定義の不一致
|
|
200
|
-
|
|
201
|
-
**解決策:**
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# 型チェック
|
|
205
|
-
npm run type-check
|
|
206
|
-
|
|
207
|
-
# node_modulesを再インストール
|
|
208
|
-
rm -rf node_modules package-lock.json
|
|
209
|
-
npm install
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### カバレッジが低い場合
|
|
213
|
-
|
|
214
|
-
**目標:** 95%以上のカバレッジ
|
|
215
|
-
|
|
216
|
-
**確認方法:**
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
npm run test:coverage:setup
|
|
220
|
-
open coverage/lcov-report/index.html
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**改善策:**
|
|
224
|
-
|
|
225
|
-
1. 未テストのエッジケースを追加
|
|
226
|
-
2. エラーハンドリングのテストを追加
|
|
227
|
-
3. モックが不十分な箇所を特定
|
|
228
|
-
|
|
229
|
-
### CI/CDが失敗する場合
|
|
230
|
-
|
|
231
|
-
**症状:** GitHub Actionsでテストが失敗
|
|
232
|
-
|
|
233
|
-
**原因1:** ローカルとCI環境の違い
|
|
234
|
-
|
|
235
|
-
**解決策:**
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
# ローカルでCI環境を再現
|
|
239
|
-
docker run -it -v $(pwd):/app node:20 bash
|
|
240
|
-
cd /app
|
|
241
|
-
npm ci
|
|
242
|
-
npm run test:integration:setup
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
**原因2:** タイムアウト
|
|
246
|
-
|
|
247
|
-
**解決策:** `.github/workflows/test-setup.yml` でタイムアウトを延長
|
|
248
|
-
|
|
249
|
-
```yaml
|
|
250
|
-
- name: Run integration tests
|
|
251
|
-
run: npm run test:integration:setup
|
|
252
|
-
timeout-minutes: 10 # デフォルト: 360分
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## ベストプラクティス
|
|
256
|
-
|
|
257
|
-
### テスト作成時
|
|
258
|
-
|
|
259
|
-
1. **TDD原則を守る**
|
|
260
|
-
- テストを先に書く
|
|
261
|
-
- 最小限の実装で通す
|
|
262
|
-
- リファクタリング
|
|
263
|
-
|
|
264
|
-
2. **テストは独立させる**
|
|
265
|
-
- 各テストは他のテストに依存しない
|
|
266
|
-
- `beforeEach`, `afterEach` でクリーンアップ
|
|
267
|
-
|
|
268
|
-
3. **意味のあるテスト名**
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
// ❌ Bad
|
|
272
|
-
it("test 1", () => {});
|
|
273
|
-
|
|
274
|
-
// ✅ Good
|
|
275
|
-
it("should create .cursor/rules directory", () => {});
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
4. **アサーションは明確に**
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
// ❌ Bad
|
|
282
|
-
expect(result).toBe(true);
|
|
283
|
-
|
|
284
|
-
// ✅ Good
|
|
285
|
-
assertDirectoryExists(
|
|
286
|
-
join(testProject.path, ".cursor/rules"),
|
|
287
|
-
"Expected .cursor/rules directory to exist",
|
|
288
|
-
);
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### テスト保守時
|
|
292
|
-
|
|
293
|
-
1. **テストが壊れたら**
|
|
294
|
-
- 実装の変更が正しいか確認
|
|
295
|
-
- テストの期待値を更新
|
|
296
|
-
- リグレッションを防ぐ
|
|
297
|
-
|
|
298
|
-
2. **新機能追加時**
|
|
299
|
-
- 必ずテストを追加
|
|
300
|
-
- カバレッジを確認
|
|
301
|
-
- エッジケースを考慮
|
|
302
|
-
|
|
303
|
-
3. **リファクタリング時**
|
|
304
|
-
- テストが通ることを確認
|
|
305
|
-
- テストコードもリファクタリング
|
|
306
|
-
- 重複を削除
|
|
307
|
-
|
|
308
|
-
## 参考資料
|
|
309
|
-
|
|
310
|
-
- [Vitest公式ドキュメント](https://vitest.dev/)
|
|
311
|
-
- [テスト戦略](../testing-strategy.md)
|
|
312
|
-
- [開発ガイド](../contributing/development.md)
|