Skip to content

Commit 5758e19

Browse files
Convert all remaining exercises to use JUnit 5 (exercism#2650)
* Convert all remaining exercises to use JUnit 5 * Fix test suite for `say` [no important files changed]
1 parent 4e1e7e9 commit 5758e19

251 files changed

Lines changed: 3842 additions & 3968 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

exercises/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ subprojects {
1313
apply plugin: "checkstyle"
1414

1515
// Add a task that copies test source files into a build directory.
16-
// All @Ignore and @Disabled annotations are removed during this copying,
16+
// All @Disabled annotations are removed during this copying,
1717
// so that when we run the copied tests, none are skipped and all should execute.
1818
tasks.register('copyTestsFilteringIgnores', Copy) {
1919
from "src/test/java"
2020
into generatedTestSourceDir
2121
filter { line ->
22-
line ==~ /.*@(Ignore|Disabled).*/ ? null : line
22+
line ==~ /.*@Disabled.*/ ? null : line
2323
}
2424
}
2525

@@ -36,7 +36,7 @@ subprojects {
3636
java.srcDirs = [".meta/src/reference/java"]
3737
}
3838

39-
// Set the directory containing the @Ignore-stripped tests as the default test source set.
39+
// Set the directory containing the @Disabled-stripped tests as the default test source set.
4040
// Default test tasks will now run against this source set.
4141
test {
4242
java.srcDirs = [generatedTestSourceDir]
@@ -80,8 +80,8 @@ subprojects {
8080
source = "src/test/java"
8181
}
8282

83-
// When running the standard test task, make sure we prepopulate the test source set with the
84-
// @Ignore-stripped tests.
83+
// When running the standard test task, make sure we pre-populate the test source set with the
84+
// @Disabled-stripped tests.
8585
compileTestJava.dependsOn(copyTestsFilteringIgnores)
8686

8787
// Enable test logging when running test task from the console
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
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 {
10-
mavenCentral()
6+
mavenCentral()
117
}
128

139
dependencies {
14-
testImplementation "junit:junit:4.13.1"
15-
testImplementation "org.assertj:assertj-core:3.25.1"
10+
testImplementation platform("org.junit:junit-bom:5.10.0")
11+
testImplementation "org.junit.jupiter:junit-jupiter"
12+
testImplementation "org.assertj:assertj-core:3.25.1"
1613
}
1714

1815
test {
19-
testLogging {
20-
exceptionFormat = 'full'
21-
showStandardStreams = true
22-
events = ["passed", "failed", "skipped"]
23-
}
16+
useJUnitPlatform()
17+
18+
testLogging {
19+
exceptionFormat = "full"
20+
showStandardStreams = true
21+
events = ["passed", "failed", "skipped"]
22+
}
2423
}

exercises/practice/acronym/src/test/java/AcronymTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import org.junit.Ignore;
2-
import org.junit.Test;
1+
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.Test;
33

44
import static org.assertj.core.api.Assertions.assertThat;
55

@@ -11,56 +11,56 @@ public void basic() {
1111
.isEqualTo("PNG");
1212
}
1313

14-
@Ignore("Remove to run test")
14+
@Disabled("Remove to run test")
1515
@Test
1616
public void lowercaseWords() {
1717
assertThat(new Acronym("Ruby on Rails").get())
1818
.isEqualTo("ROR");
1919
}
2020

21-
@Ignore("Remove to run test")
21+
@Disabled("Remove to run test")
2222
@Test
2323
public void punctuation() {
2424
assertThat(new Acronym("First In, First Out").get())
2525
.isEqualTo("FIFO");
2626
}
2727

28-
@Ignore("Remove to run test")
28+
@Disabled("Remove to run test")
2929
@Test
3030
public void nonAcronymAllCapsWord() {
3131
assertThat(new Acronym("GNU Image Manipulation Program").get())
3232
.isEqualTo("GIMP");
3333
}
3434

35-
@Ignore("Remove to run test")
35+
@Disabled("Remove to run test")
3636
@Test
3737
public void punctuationWithoutWhitespace() {
3838
assertThat(new Acronym("Complementary metal-oxide semiconductor").get())
3939
.isEqualTo("CMOS");
4040
}
4141

42-
@Ignore("Remove to run test")
42+
@Disabled("Remove to run test")
4343
@Test
4444
public void veryLongAbbreviation() {
4545
assertThat(new Acronym("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me").get())
4646
.isEqualTo("ROTFLSHTMDCOALM");
4747
}
4848

49-
@Ignore("Remove to run test")
49+
@Disabled("Remove to run test")
5050
@Test
5151
public void consecutiveDelimiters() {
5252
assertThat(new Acronym("Something - I made up from thin air").get())
5353
.isEqualTo("SIMUFTA");
5454
}
5555

56-
@Ignore("Remove to run test")
56+
@Disabled("Remove to run test")
5757
@Test
5858
public void apostrophes() {
5959
assertThat(new Acronym("Halley's Comet").get())
6060
.isEqualTo("HC");
6161
}
6262

63-
@Ignore("Remove to run test")
63+
@Disabled("Remove to run test")
6464
@Test
6565
public void underscoreEmphasis() {
6666
assertThat(new Acronym("The Road _Not_ Taken").get())
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
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 {
10-
mavenCentral()
6+
mavenCentral()
117
}
128

139
dependencies {
14-
testImplementation "junit:junit:4.13.1"
15-
testImplementation "org.assertj:assertj-core:3.25.1"
10+
testImplementation platform("org.junit:junit-bom:5.10.0")
11+
testImplementation "org.junit.jupiter:junit-jupiter"
12+
testImplementation "org.assertj:assertj-core:3.25.1"
1613
}
1714

1815
test {
19-
testLogging {
20-
exceptionFormat = 'full'
21-
showStandardStreams = true
22-
events = ["passed", "failed", "skipped"]
23-
}
16+
useJUnitPlatform()
17+
18+
testLogging {
19+
exceptionFormat = "full"
20+
showStandardStreams = true
21+
events = ["passed", "failed", "skipped"]
22+
}
2423
}

exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import org.junit.Ignore;
2-
import org.junit.Test;
1+
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.Test;
33

44
import static org.assertj.core.api.Assertions.assertThat;
55
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -13,103 +13,103 @@ public void testEncodeYes() {
1313
assertThat(affineCipher.encode("yes", 5, 7)).isEqualTo("xbt");
1414
}
1515

16-
@Ignore("Remove to run test")
16+
@Disabled("Remove to run test")
1717
@Test
1818
public void testEncodeNo() {
1919
assertThat(affineCipher.encode("no", 15, 18)).isEqualTo("fu");
2020
}
2121

2222

23-
@Ignore("Remove to run test")
23+
@Disabled("Remove to run test")
2424
@Test
2525
public void testEncodeOMG() {
2626
assertThat(affineCipher.encode("OMG", 21, 3)).isEqualTo("lvz");
2727
}
2828

29-
@Ignore("Remove to run test")
29+
@Disabled("Remove to run test")
3030
@Test
3131
public void testEncodeO_M_G() {
3232
assertThat(affineCipher.encode("O M G", 25, 47)).isEqualTo("hjp");
3333
}
3434

35-
@Ignore("Remove to run test")
35+
@Disabled("Remove to run test")
3636
@Test
3737
public void testEncodeMindBlowingly() {
3838
assertThat(affineCipher.encode("mindblowingly", 11, 15)).isEqualTo("rzcwa gnxzc dgt");
3939
}
4040

41-
@Ignore("Remove to run test")
41+
@Disabled("Remove to run test")
4242
@Test
4343
public void testEncodeNumbers() {
4444
assertThat(affineCipher.encode("Testing,1 2 3, testing.", 3, 4))
4545
.isEqualTo("jqgjc rw123 jqgjc rw");
4646
}
4747

48-
@Ignore("Remove to run test")
48+
@Disabled("Remove to run test")
4949
@Test
5050
public void testEncodeDeepThought() {
5151
assertThat(affineCipher.encode("Truth is fiction.", 5, 17))
5252
.isEqualTo("iynia fdqfb ifje");
5353
}
5454

55-
@Ignore("Remove to run test")
55+
@Disabled("Remove to run test")
5656
@Test
5757
public void testEncodeAllTheLetters() {
5858
assertThat(affineCipher.encode("The quick brown fox jumps over the lazy dog.", 17, 33))
5959
.isEqualTo("swxtj npvyk lruol iejdc blaxk swxmh qzglf");
6060
}
6161

62-
@Ignore("Remove to run test")
62+
@Disabled("Remove to run test")
6363
@Test
6464
public void testEncodeThrowsMeaningfulException() {
6565
assertThatExceptionOfType(IllegalArgumentException.class)
6666
.isThrownBy(() -> affineCipher.encode("This is a test", 6, 17))
6767
.withMessage("Error: keyA and alphabet size must be coprime.");
6868
}
6969

70-
@Ignore("Remove to run test")
70+
@Disabled("Remove to run test")
7171
@Test
7272
public void testDecodeExercism() {
7373
assertThat(affineCipher.decode("tytgn fjr", 3, 7))
7474
.isEqualTo("exercism");
7575
}
7676

77-
@Ignore("Remove to run test")
77+
@Disabled("Remove to run test")
7878
@Test
7979
public void testDecodeSentence() {
8080
assertThat(affineCipher.decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16))
8181
.isEqualTo("anobstacleisoftenasteppingstone");
8282
}
8383

84-
@Ignore("Remove to run test")
84+
@Disabled("Remove to run test")
8585
@Test
8686
public void testDecodeNumbers() {
8787
assertThat(affineCipher.decode("odpoz ub123 odpoz ub", 25, 7))
8888
.isEqualTo("testing123testing");
8989
}
9090

91-
@Ignore("Remove to run test")
91+
@Disabled("Remove to run test")
9292
@Test
9393
public void testDecodeAllTheLetters() {
9494
assertThat(affineCipher.decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33))
9595
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
9696
}
9797

98-
@Ignore("Remove to run test")
98+
@Disabled("Remove to run test")
9999
@Test
100100
public void testDecodeWithNoSpaces() {
101101
assertThat(affineCipher.decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33))
102102
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
103103
}
104104

105-
@Ignore("Remove to run test")
105+
@Disabled("Remove to run test")
106106
@Test
107107
public void testDecodeWithTooManySpaces() {
108108
assertThat(affineCipher.decode("vszzm cly yd cg qdp", 15, 16))
109109
.isEqualTo("jollygreengiant");
110110
}
111111

112-
@Ignore("Remove to run test")
112+
@Disabled("Remove to run test")
113113
@Test
114114
public void testDecodeThrowsMeaningfulException() {
115115
assertThatExceptionOfType(IllegalArgumentException.class)
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
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 {
10-
mavenCentral()
6+
mavenCentral()
117
}
128

139
dependencies {
14-
testImplementation "junit:junit:4.13.1"
15-
testImplementation "org.assertj:assertj-core:3.25.1"
10+
testImplementation platform("org.junit:junit-bom:5.10.0")
11+
testImplementation "org.junit.jupiter:junit-jupiter"
12+
testImplementation "org.assertj:assertj-core:3.25.1"
1613
}
1714

1815
test {
19-
testLogging {
20-
exceptionFormat = 'full'
21-
showStandardStreams = true
22-
events = ["passed", "failed", "skipped"]
23-
}
16+
useJUnitPlatform()
17+
18+
testLogging {
19+
exceptionFormat = "full"
20+
showStandardStreams = true
21+
events = ["passed", "failed", "skipped"]
22+
}
2423
}

0 commit comments

Comments
 (0)