Claude ec9ace9c54 docs: add native Japanese translation of ECC documentation (ja-JP)
Translate everything-claude-code repository to Japanese including:
- 17 root documentation files
- 60 agent documentation files
- 80 command documentation files
- 99 rule files across 18 language directories (common, angular, arkts, cpp, csharp, dart, fsharp, golang, java, kotlin, perl, php, python, ruby, rust, swift, typescript, web)
- 199 skill documentation files

Total: 455 files translated to Japanese with:
- Consistent terminology glossary applied throughout
- YAML field names preserved in English (name, description, etc.)
- Code blocks and examples untouched (comments translated)
- Markdown structure and relative links preserved
- Professional translation maintaining technical accuracy

This translation expands ECC accessibility to Japanese-speaking developers and teams.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-17 02:31:40 -04:00

129 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
paths:
- "**/*.kt"
- "**/*.kts"
---
# Kotlin テスト
> このファイルは [common/testing.md](../common/testing.md) を Kotlin および Android/KMP 固有のコンテンツで拡張します。
## テストフレームワーク
- **kotlin.test** — マルチプラットフォームKMP`@Test``assertEquals``assertTrue`
- **JUnit 4/5** — Android 固有のテスト用
- **Turbine** — Flow と StateFlow のテスト用
- **kotlinx-coroutines-test** — コルーチンテスト用(`runTest``TestDispatcher`
## Turbine を使った ViewModel テスト
```kotlin
@Test
fun `loading state emitted then data`() = runTest {
val repo = FakeItemRepository()
repo.addItem(testItem)
val viewModel = ItemListViewModel(GetItemsUseCase(repo))
viewModel.state.test {
assertEquals(ItemListState(), awaitItem()) // 初期状態
viewModel.onEvent(ItemListEvent.Load)
assertTrue(awaitItem().isLoading) // ローディング中
assertEquals(listOf(testItem), awaitItem().items) // ロード完了
}
}
```
## モックよりもフェイクを優先
モッキングフレームワークよりも手書きのフェイクを優先する:
```kotlin
class FakeItemRepository : ItemRepository {
private val items = mutableListOf<Item>()
var fetchError: Throwable? = null
override suspend fun getAll(): Result<List<Item>> {
fetchError?.let { return Result.failure(it) }
return Result.success(items.toList())
}
override fun observeAll(): Flow<List<Item>> = flowOf(items.toList())
fun addItem(item: Item) { items.add(item) }
}
```
## コルーチンテスト
```kotlin
@Test
fun `parallel operations complete`() = runTest {
val repo = FakeRepository()
val result = loadDashboard(repo)
advanceUntilIdle()
assertNotNull(result.items)
assertNotNull(result.stats)
}
```
`runTest` を使用する — 仮想時間を自動的に進め、`TestScope` を提供する。
## Ktor MockEngine
```kotlin
val mockEngine = MockEngine { request ->
when (request.url.encodedPath) {
"/api/items" -> respond(
content = Json.encodeToString(testItems),
headers = headersOf(HttpHeaders.ContentType, ContentType.Application.Json.toString())
)
else -> respondError(HttpStatusCode.NotFound)
}
}
val client = HttpClient(mockEngine) {
install(ContentNegotiation) { json() }
}
```
## Room/SQLDelight テスト
- Room: インメモリテストには `Room.inMemoryDatabaseBuilder()` を使用
- SQLDelight: JVM テストには `JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)` を使用
```kotlin
@Test
fun `insert and query items`() = runTest {
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
Database.Schema.create(driver)
val db = Database(driver)
db.itemQueries.insert("1", "Sample Item", "description")
val items = db.itemQueries.getAll().executeAsList()
assertEquals(1, items.size)
}
```
## テスト命名
バッククォートで囲んだ説明的な名前を使用する:
```kotlin
@Test
fun `search with empty query returns all items`() = runTest { }
@Test
fun `delete item emits updated list without deleted item`() = runTest { }
```
## テストの構成
```
src/
├── commonTest/kotlin/ # 共有テストViewModel、UseCase、Repository
├── androidUnitTest/kotlin/ # Android ユニットテストJUnit
├── androidInstrumentedTest/kotlin/ # インストルメンテッドテストRoom、UI
└── iosTest/kotlin/ # iOS 固有のテスト
```
最低限のテストカバレッジ: すべての機能に対して ViewModel + UseCase。