Given(前提条件) val language = "ja" val country = "JP" // When(操作) val url = get(language = language, country = country) // Then(結果) Truth.assertThat(url).isEqualTo("https://localhost/help/ja/JP/") } // 実装 fun get(language: String, country: String): String { return "" } ଓઌใͱͷݴޠઃఆʹԠͨ͡ϔϧϓϖʔδͷ63-Λੜ͢Δ ❌ຊޠຊαʔόʔͷ߹ͤ RED
Given(前提条件) val language = "ja" val country = "JP" // When(操作) val url = get(language = language, country = country) // Then(結果) Truth.assertThat(url).isEqualTo("https://localhost/help/ja/JP/") } // 実装 fun get(language: String, country: String): String { return "https://localhost/help/ja/JP/" } ଓઌใͱͷݴޠઃఆʹԠͨ͡ϔϧϓϖʔδͷ63-Λੜ͢Δ ✅ຊޠຊαʔόʔͷ߹ͤ GREEN
Given(前提条件) val language = "ja" val country = "JP" // When(操作) val url = get(language = language, country = country) // Then(結果) Truth.assertThat(url).isEqualTo("https://localhost/help/ja/JP/") } @Test fun `英語 / 日本サーバー の組合せで、ヘルプページのURLを生成する` { // Given val language = "en" val country = "JP" // When val url = get(language = language, country = country) // Then Truth.assertThat(url).isEqualTo("https://localhost/help/en/JP/") } // 実装 fun get(language: String, country: String): String { return "https://localhost/help/ja/JP/" } ଓઌใͱͷݴޠઃఆʹԠͨ͡ϔϧϓϖʔδͷ63-Λੜ͢Δ ✅ຊޠຊαʔόʔͷ߹ͤ ❌ ӳޠຊαʔόʔͷ߹ͤ RED
Given(前提条件) val language = "ja" val country = "JP" // When(操作) val url = get(language = language, country = country) // Then(結果) Truth.assertThat(url).isEqualTo("https://localhost/help/ja/JP/") } @Test fun `英語 / 日本サーバー の組合せで、ヘルプページのURLを生成する` { // Given val language = "en" val country = "JP" // When val url = get(language = language, country = country) // Then Truth.assertThat(url).isEqualTo("https://localhost/help/en/JP/") } // 実装 fun get(language: String, country: String): String { if (language == "en") { return "https://localhost/help/en/JP/" } else { return "https://localhost/help/ja/JP/" } } ଓઌใͱͷݴޠઃఆʹԠͨ͡ϔϧϓϖʔδͷ63-Λੜ͢Δ ✅ຊޠຊαʔόʔͷ߹ͤ ✅ ӳޠຊαʔόʔͷ߹ͤ GREEN
Given(前提条件) val language = "ja" val country = "JP" // When(操作) val url = generateHelpLink(language = language, country = country) // Then(結果) Truth.assertThat(url).isEqualTo("https://localhost/help/ja/JP/") } @Test fun `英語 / 日本サーバー の組合せで、ヘルプページのURLを生成する` { // Given val language = "en" val country = "JP" // When val url = generateHelpLink(language = language, country = country) // Then Truth.assertThat(url).isEqualTo("https://localhost/help/en/JP/") } // 実装 fun generateHelpLink(language: String, country: String): String { val helpPath = when (language) { "en" -> "en/JP" else -> "ja/JP" } return "https://localhost/help/$helpPath/" } ଓઌใͱͷݴޠઃఆʹԠͨ͡ϔϧϓϖʔδͷ63-Λੜ͢Δ ✅ຊޠຊαʔόʔͷ߹ͤ ✅ ӳޠຊαʔόʔͷ߹ͤ REFACTOR