diff --git a/exercises/concept/karls-languages/build.gradle b/exercises/concept/karls-languages/build.gradle index 8bd005d42..8c21cae73 100644 --- a/exercises/concept/karls-languages/build.gradle +++ b/exercises/concept/karls-languages/build.gradle @@ -1,23 +1,22 @@ -apply plugin: "java" -apply plugin: "eclipse" -apply plugin: "idea" - -// set default encoding to UTF-8 -compileJava.options.encoding = "UTF-8" -compileTestJava.options.encoding = "UTF-8" +plugins { + id "java" +} repositories { mavenCentral() } dependencies { - testImplementation "junit:junit:4.13" + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" testImplementation "org.assertj:assertj-core:3.15.0" } test { + useJUnitPlatform() + testLogging { - exceptionFormat = 'full' + exceptionFormat = "full" showStandardStreams = true events = ["passed", "failed", "skipped"] } diff --git a/exercises/concept/karls-languages/src/test/java/LanguageListTest.java b/exercises/concept/karls-languages/src/test/java/LanguageListTest.java index c618e3305..551d6cfc9 100644 --- a/exercises/concept/karls-languages/src/test/java/LanguageListTest.java +++ b/exercises/concept/karls-languages/src/test/java/LanguageListTest.java @@ -1,17 +1,23 @@ -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.assertj.core.api.Assertions.*; public class LanguageListTest { LanguageList languageList = new LanguageList(); @Test + @Tag("task:1") + @DisplayName("The isEmpty method returns true when the list contains no languages") public void empty() { assertThat(languageList.isEmpty()).isTrue(); } @Test + @Tag("task:2") + @DisplayName("The isEmpty method returns false after adding a language to the list") public void nonEmpty() { languageList.addLanguage("Java"); @@ -19,39 +25,18 @@ public void nonEmpty() { } @Test - public void addOneLanguage() { - languageList.addLanguage("Java"); - - assertThat(languageList.containsLanguage("Java")).isTrue(); - assertThat(languageList.containsLanguage("Python")).isFalse(); - } - - @Test - public void addMultipleLanguages() { - languageList.addLanguage("Java"); - languageList.addLanguage("Ruby"); - languageList.addLanguage("C++"); - - assertThat(languageList.containsLanguage("Java")).isTrue(); - assertThat(languageList.containsLanguage("Ruby")).isTrue(); - assertThat(languageList.containsLanguage("C++")).isTrue(); - assertThat(languageList.containsLanguage("Python")).isFalse(); - } - - @Test + @Tag("task:3") + @DisplayName("The removeLanguage method correctly removes a language from the list") public void removeLanguage() { languageList.addLanguage("Java"); - languageList.addLanguage("Python"); - languageList.addLanguage("Ruby"); - - languageList.removeLanguage("Python"); + languageList.removeLanguage("Java"); - assertThat(languageList.containsLanguage("Java")).isTrue(); - assertThat(languageList.containsLanguage("Python")).isFalse(); - assertThat(languageList.containsLanguage("Ruby")).isTrue(); + assertThat(languageList.isEmpty()).isTrue(); } @Test + @Tag("task:4") + @DisplayName("The firstLanguage method returns the first language that was added to the list") public void firstLanguage() { languageList.addLanguage("Java"); languageList.addLanguage("Python"); @@ -61,6 +46,8 @@ public void firstLanguage() { } @Test + @Tag("task:5") + @DisplayName("The count method returns the number of languages in the list") public void countThree() { languageList.addLanguage("Java"); languageList.addLanguage("Python"); @@ -70,11 +57,33 @@ public void countThree() { } @Test + @Tag("task:5") + @DisplayName("The count method returns 0 when the list is empty") public void countEmpty() { assertThat(languageList.count()).isEqualTo(0); } @Test + @Tag("task:6") + @DisplayName("The containsLanguage method returns true when the language is in the list") + public void containsLanguage() { + languageList.addLanguage("Java"); + + assertThat(languageList.containsLanguage("Java")).isTrue(); + } + + @Test + @Tag("task:6") + @DisplayName("The containsLanguage method returns false when the language is not in the list") + public void doesNotContainLanguage() { + languageList.addLanguage("Kotlin"); + + assertThat(languageList.containsLanguage("Java")).isFalse(); + } + + @Test + @Tag("task:7") + @DisplayName("The isExciting method returns true when the list contains Java") public void excitingLanguageListWithJava() { languageList.addLanguage("Java"); @@ -82,6 +91,8 @@ public void excitingLanguageListWithJava() { } @Test + @Tag("task:7") + @DisplayName("The isExciting method returns true when the list contains Kotlin") public void excitingLanguageListWithKotlin() { languageList.addLanguage("Python"); languageList.addLanguage("Kotlin"); @@ -90,6 +101,8 @@ public void excitingLanguageListWithKotlin() { } @Test + @Tag("task:7") + @DisplayName("The isExciting method returns false when the list contains neither Java nor Kotlin") public void boringLanguageList() { languageList.addLanguage("Python"); languageList.addLanguage("Ruby");