From ab74222dbc21b5098c2e55139865bcebc82168b9 Mon Sep 17 00:00:00 2001 From: Atharv Patil Date: Mon, 8 Sep 2025 21:32:39 +0530 Subject: [PATCH 1/2] hamming, hello-world, high-scores, house --- .../hamming/src/test/java/HammingTest.java | 10 ++++++++++ .../hello-world/src/test/java/GreeterTest.java | 2 ++ .../high-scores/src/test/java/HighScoresTest.java | 13 +++++++++++++ .../practice/house/src/test/java/HouseTest.java | 15 +++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/exercises/practice/hamming/src/test/java/HammingTest.java b/exercises/practice/hamming/src/test/java/HammingTest.java index 5f9082e35..26f22491f 100644 --- a/exercises/practice/hamming/src/test/java/HammingTest.java +++ b/exercises/practice/hamming/src/test/java/HammingTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -7,36 +8,42 @@ public class HammingTest { @Test + @DisplayName("empty strands") public void testNoDistanceBetweenEmptyStrands() { assertThat(new Hamming("", "").getHammingDistance()).isEqualTo(0); } @Disabled("Remove to run test") @Test + @DisplayName("single letter identical strands") public void testNoDistanceBetweenShortIdenticalStrands() { assertThat(new Hamming("A", "A").getHammingDistance()).isEqualTo(0); } @Disabled("Remove to run test") @Test + @DisplayName("single letter different strands") public void testCompleteDistanceInSingleLetterDifferentStrands() { assertThat(new Hamming("G", "T").getHammingDistance()).isEqualTo(1); } @Disabled("Remove to run test") @Test + @DisplayName("long identical strands") public void testDistanceInLongIdenticalStrands() { assertThat(new Hamming("GGACTGAAATCTG", "GGACTGAAATCTG").getHammingDistance()).isEqualTo(0); } @Disabled("Remove to run test") @Test + @DisplayName("long different strands") public void testDistanceInLongDifferentStrands() { assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance()).isEqualTo(9); } @Disabled("Remove to run test") @Test + @DisplayName("disallow first strand longer") public void testValidatesFirstStrandNotLonger() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new Hamming("AATG", "AAA")) @@ -45,6 +52,7 @@ public void testValidatesFirstStrandNotLonger() { @Disabled("Remove to run test") @Test + @DisplayName("disallow second strand longer") public void testValidatesSecondStrandNotLonger() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new Hamming("ATA", "AGTG")) @@ -53,6 +61,7 @@ public void testValidatesSecondStrandNotLonger() { @Disabled("Remove to run test") @Test + @DisplayName("disallow left empty strand") public void testDisallowLeftEmptyStrand() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new Hamming("", "G")) @@ -61,6 +70,7 @@ public void testDisallowLeftEmptyStrand() { @Disabled("Remove to run test") @Test + @DisplayName("disallow right empty strand") public void testDisallowRightEmptyStrand() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new Hamming("G", "")) diff --git a/exercises/practice/hello-world/src/test/java/GreeterTest.java b/exercises/practice/hello-world/src/test/java/GreeterTest.java index fc25c1891..cd5fb79a3 100644 --- a/exercises/practice/hello-world/src/test/java/GreeterTest.java +++ b/exercises/practice/hello-world/src/test/java/GreeterTest.java @@ -1,3 +1,4 @@ +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -5,6 +6,7 @@ public class GreeterTest { @Test + @DisplayName("Say Hi!") public void testThatGreeterReturnsTheCorrectGreeting() { assertThat(new Greeter().getGreeting()).isEqualTo("Hello, World!"); } diff --git a/exercises/practice/high-scores/src/test/java/HighScoresTest.java b/exercises/practice/high-scores/src/test/java/HighScoresTest.java index 15fd8eaa4..1133e9f45 100644 --- a/exercises/practice/high-scores/src/test/java/HighScoresTest.java +++ b/exercises/practice/high-scores/src/test/java/HighScoresTest.java @@ -1,6 +1,7 @@ import java.util.Arrays; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,6 +9,7 @@ public class HighScoresTest { @Test + @DisplayName("List of scores") public void shouldReturnListOfScores() { HighScores highScores = new HighScores(Arrays.asList(30, 50, 20, 70)); assertThat(highScores.scores()).isEqualTo(Arrays.asList(30, 50, 20, 70)); @@ -15,6 +17,7 @@ public void shouldReturnListOfScores() { @Test @Disabled("Remove to run test") + @DisplayName("Latest score") public void shouldReturnLatestAddedScore() { HighScores highScores = new HighScores(Arrays.asList(100, 0, 90, 30)); assertThat(highScores.latest()).isEqualTo(30); @@ -22,6 +25,7 @@ public void shouldReturnLatestAddedScore() { @Test @Disabled("Remove to run test") + @DisplayName("Personal best") public void shouldReturnPersonalBest() { HighScores highScores = new HighScores(Arrays.asList(40, 100, 70)); assertThat(highScores.personalBest()).isEqualTo(100); @@ -29,6 +33,7 @@ public void shouldReturnPersonalBest() { @Test @Disabled("Remove to run test") + @DisplayName("Personal top three from a list of scores") public void shouldReturnPersonalTopThreeFromListOfScores() { HighScores highScores = new HighScores(Arrays.asList(10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(100, 90, 70)); @@ -36,6 +41,7 @@ public void shouldReturnPersonalTopThreeFromListOfScores() { @Test @Disabled("Remove to run test") + @DisplayName("") public void shouldReturnPersonalTopThreeSortedHighestToLowest() { HighScores highScores = new HighScores(Arrays.asList(20, 10, 30)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(30, 20, 10)); @@ -43,6 +49,7 @@ public void shouldReturnPersonalTopThreeSortedHighestToLowest() { @Test @Disabled("Remove to run test") + @DisplayName("Personal top when there is a tie") public void shouldReturnPersonalTopThreeWhenThereIsATie() { HighScores highScores = new HighScores(Arrays.asList(40, 20, 40, 30)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(40, 40, 30)); @@ -50,6 +57,7 @@ public void shouldReturnPersonalTopThreeWhenThereIsATie() { @Test @Disabled("Remove to run test") + @DisplayName("Personal top when there are less than 3") public void shouldReturnPersonalTopWhenThereIsLessThanThreeScores() { HighScores highScores = new HighScores(Arrays.asList(30, 70)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(70, 30)); @@ -57,6 +65,7 @@ public void shouldReturnPersonalTopWhenThereIsLessThanThreeScores() { @Test @Disabled("Remove to run test") + @DisplayName("Personal top when there is only one") public void shouldReturnPersonalTopWhenThereIsOnlyOneScore() { HighScores highScores = new HighScores(Arrays.asList(40)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(40)); @@ -64,6 +73,7 @@ public void shouldReturnPersonalTopWhenThereIsOnlyOneScore() { @Test @Disabled("Remove to run test") + @DisplayName("Latest score after personal top scores") public void callingLatestAfterPersonalTopThree() { HighScores highScores = new HighScores(Arrays.asList(70, 50, 20, 30)); highScores.personalTopThree(); @@ -72,6 +82,7 @@ public void callingLatestAfterPersonalTopThree() { @Test @Disabled("Remove to run test") + @DisplayName("Scores after personal top scores") public void callingScoresAfterPersonalTopThree() { HighScores highScores = new HighScores(Arrays.asList(30, 50, 20, 70)); highScores.personalTopThree(); @@ -80,6 +91,7 @@ public void callingScoresAfterPersonalTopThree() { @Test @Disabled("Remove to run test") + @DisplayName("Latest score after personal best") public void callingLatestAfterPersonalBest() { HighScores highScores = new HighScores(Arrays.asList(20, 70, 15, 25, 30)); highScores.personalBest(); @@ -88,6 +100,7 @@ public void callingLatestAfterPersonalBest() { @Test @Disabled("Remove to run test") + @DisplayName("Scores after personal best") public void callingScoresAfterPersonalBest() { HighScores highScores = new HighScores(Arrays.asList(20, 70, 15, 25, 30)); highScores.personalBest(); diff --git a/exercises/practice/house/src/test/java/HouseTest.java b/exercises/practice/house/src/test/java/HouseTest.java index 08c3d3c2e..4841a9d14 100644 --- a/exercises/practice/house/src/test/java/HouseTest.java +++ b/exercises/practice/house/src/test/java/HouseTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.BeforeEach; import static org.assertj.core.api.Assertions.assertThat; @@ -14,6 +15,7 @@ public void setup() { } @Test + @DisplayName("verse one - the house that jack built") public void verseOne() { assertThat(house.verse(1)).isEqualTo( "This is the house that Jack built."); @@ -21,6 +23,7 @@ public void verseOne() { @Disabled("Remove to run test") @Test + @DisplayName("verse two - the malt that lay") public void verseTwo() { assertThat(house.verse(2)).isEqualTo( "This is the malt " + @@ -30,6 +33,7 @@ public void verseTwo() { @Disabled("Remove to run test") @Test + @DisplayName("verse three - the rat that ate") public void verseThree() { assertThat(house.verse(3)).isEqualTo( "This is the rat " + @@ -39,6 +43,7 @@ public void verseThree() { @Disabled("Remove to run test") @Test + @DisplayName("verse four - the cat that killed") public void verseFour() { assertThat(house.verse(4)).isEqualTo( "This is the cat " + @@ -49,6 +54,7 @@ public void verseFour() { @Disabled("Remove to run test") @Test + @DisplayName("verse five - the dog that worried") public void verseFive() { assertThat(house.verse(5)).isEqualTo( "This is the dog " + @@ -60,6 +66,7 @@ public void verseFive() { @Disabled("Remove to run test") @Test + @DisplayName("verse six - the cow with the crumpled horn") public void verseSix() { assertThat(house.verse(6)).isEqualTo( "This is the cow with the crumpled horn " + @@ -72,6 +79,7 @@ public void verseSix() { @Disabled("Remove to run test") @Test + @DisplayName("verse seven - the maiden all forlorn") public void verseSeven() { assertThat(house.verse(7)).isEqualTo( "This is the maiden all forlorn " + @@ -85,6 +93,7 @@ public void verseSeven() { @Disabled("Remove to run test") @Test + @DisplayName("verse eight - the man all tattered and torn") public void verseEight() { assertThat(house.verse(8)).isEqualTo( "This is the man all tattered and torn " + @@ -99,6 +108,7 @@ public void verseEight() { @Disabled("Remove to run test") @Test + @DisplayName("verse nine - the priest all shaven and shorn") public void verseNine() { assertThat(house.verse(9)).isEqualTo( "This is the priest all shaven and shorn " + @@ -114,6 +124,7 @@ public void verseNine() { @Disabled("Remove to run test") @Test + @DisplayName("verse 10 - the rooster that crowed in the morn") public void verse10() { assertThat(house.verse(10)).isEqualTo( "This is the rooster that crowed in the morn " + @@ -130,6 +141,7 @@ public void verse10() { @Disabled("Remove to run test") @Test + @DisplayName("verse 11 - the farmer sowing his corn") public void verse11() { assertThat(house.verse(11)).isEqualTo( "This is the farmer sowing his corn " + @@ -147,6 +159,7 @@ public void verse11() { @Disabled("Remove to run test") @Test + @DisplayName("verse 12 - the horse and the hound and the horn") public void verse12() { assertThat(house.verse(12)).isEqualTo( "This is the horse and the hound and the horn " + @@ -165,6 +178,7 @@ public void verse12() { @Disabled("Remove to run test") @Test + @DisplayName("multiple verses") public void multipleVerses() { int startVerse = 4; int endVerse = 8; @@ -204,6 +218,7 @@ public void multipleVerses() { @Disabled("Remove to run test") @Test + @DisplayName("full rhyme") public void wholeRhyme() { assertThat(house.sing()).isEqualTo( "This is the house that Jack built.\n" + From a301edf7d01e79507427e4ea704fd9038e791573 Mon Sep 17 00:00:00 2001 From: Atharv Patil Date: Tue, 9 Sep 2025 08:59:11 +0530 Subject: [PATCH 2/2] Update HighScoresTest.java --- .../practice/high-scores/src/test/java/HighScoresTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/high-scores/src/test/java/HighScoresTest.java b/exercises/practice/high-scores/src/test/java/HighScoresTest.java index 1133e9f45..282d09c6e 100644 --- a/exercises/practice/high-scores/src/test/java/HighScoresTest.java +++ b/exercises/practice/high-scores/src/test/java/HighScoresTest.java @@ -41,7 +41,7 @@ public void shouldReturnPersonalTopThreeFromListOfScores() { @Test @Disabled("Remove to run test") - @DisplayName("") + @DisplayName("Personal top highest to lowest") public void shouldReturnPersonalTopThreeSortedHighestToLowest() { HighScores highScores = new HighScores(Arrays.asList(20, 10, 30)); assertThat(highScores.personalTopThree()).isEqualTo(Arrays.asList(30, 20, 10));