Skip to content

Commit c94babb

Browse files
authored
Update squeaky clean to use test runner v3 features (#2498)
* Update squeaky clean to use test runner v3 features * added tag in last test
1 parent 41c92de commit c94babb

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

exercises/concept/squeaky-clean/build.gradle

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
apply plugin: "java"
2-
apply plugin: "eclipse"
3-
apply plugin: "idea"
4-
5-
// set default encoding to UTF-8
6-
compileJava.options.encoding = "UTF-8"
7-
compileTestJava.options.encoding = "UTF-8"
1+
plugins {
2+
id "java"
3+
}
84

95
repositories {
106
mavenCentral()
117
}
128

139
dependencies {
14-
testImplementation "junit:junit:4.13"
10+
testImplementation platform("org.junit:junit-bom:5.10.0")
11+
testImplementation "org.junit.jupiter:junit-jupiter"
1512
testImplementation "org.assertj:assertj-core:3.15.0"
1613
}
1714

1815
test {
16+
useJUnitPlatform()
17+
1918
testLogging {
20-
exceptionFormat = 'full'
19+
exceptionFormat = "full"
2120
showStandardStreams = true
2221
events = ["passed", "failed", "skipped"]
2322
}

exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,91 @@
1-
import org.junit.Test;
1+
import org.junit.jupiter.api.DisplayName;
2+
import org.junit.jupiter.api.Tag;
3+
import org.junit.jupiter.api.Test;
24

35
import static org.assertj.core.api.Assertions.assertThat;
46

57
public class SqueakyCleanTest {
68

79
@Test
10+
@Tag("task:1")
11+
@DisplayName("The clean method returns empty string when invoked on empty string")
812
public void empty() {
913
assertThat(SqueakyClean.clean("")).isEmpty();
1014
}
1115

1216
@Test
17+
@Tag("task:1")
18+
@DisplayName("The clean method returns the same string when invoked on a single letter string")
1319
public void single_letter() {
1420
assertThat(SqueakyClean.clean("A")).isEqualTo("A");
1521
}
1622

1723
@Test
24+
@Tag("task:1")
25+
@DisplayName("The clean method returns the same string when invoked on a string of three letters")
1826
public void string() {
1927
assertThat(SqueakyClean.clean("àḃç")).isEqualTo("àḃç");
2028
}
2129

2230
@Test
31+
@Tag("task:1")
32+
@DisplayName("The clean method replaces whitespaces with underscores in the middle of the string")
2333
public void spaces() {
2434
assertThat(SqueakyClean.clean("my Id")).isEqualTo("my___Id");
2535
}
2636

2737
@Test
38+
@Tag("task:1")
39+
@DisplayName("The clean method replaces leading and trailing whitespaces with underscores")
2840
public void leading_and_trailing_spaces() {
2941
assertThat(SqueakyClean.clean(" myId ")).isEqualTo("_myId_");
3042
}
3143

3244
@Test
45+
@Tag("task:2")
46+
@DisplayName("The clean method replaces control characters with CTRL")
3347
public void ctrl() {
3448
assertThat(SqueakyClean.clean("my\0\r\u007FId")).isEqualTo("myCTRLCTRLCTRLId");
3549
}
3650

3751
@Test
52+
@Tag("task:4")
53+
@DisplayName("The clean method returns an empty string when invoked on a string with no letters")
3854
public void string_with_no_letters() {
3955
assertThat(SqueakyClean.clean("\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00")).isEmpty();
4056
}
4157

4258
@Test
43-
public void keep_only_letters() {
44-
assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab");
45-
}
46-
47-
@Test
59+
@Tag("task:3")
60+
@DisplayName("The clean method converts kebab to camel case after removing a dash")
4861
public void kebab_to_camel_case() {
4962
assertThat(SqueakyClean.clean("à-ḃç")).isEqualTo("àḂç");
5063
}
5164

5265
@Test
66+
@Tag("task:3")
67+
@DisplayName("The clean method returns a string in camel case after removing a dash and a number")
5368
public void kebab_to_camel_case_no_letter() {
5469
assertThat(SqueakyClean.clean("a-1C")).isEqualTo("aC");
5570
}
5671

5772
@Test
73+
@Tag("task:4")
74+
@DisplayName("The clean method removes all characters that are not letters")
75+
public void keep_only_letters() {
76+
assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab");
77+
}
78+
79+
@Test
80+
@Tag("task:5")
81+
@DisplayName("The clean method removes all lowercase greek letters")
5882
public void omit_lower_case_greek_letters() {
5983
assertThat(SqueakyClean.clean("MyΟβιεγτFinder")).isEqualTo("MyΟFinder");
6084
}
6185

6286
@Test
87+
@Tag("task:5")
88+
@DisplayName("The clean method returns the correct result after performing a few cleaning operations")
6389
public void combine_conversions() {
6490
assertThat(SqueakyClean.clean("9 -abcĐ\uD83D\uDE00ω\0")).isEqualTo("_AbcĐCTRL");
6591
}

0 commit comments

Comments
 (0)