Skip to content

Commit c173950

Browse files
authored
Update annalyns infiltration to use test runner v3 features (#2504)
1 parent f284f24 commit c173950

File tree

2 files changed

+74
-11
lines changed

2 files changed

+74
-11
lines changed

exercises/concept/annalyns-infiltration/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/annalyns-infiltration/src/test/java/AnnalynsInfiltrationTest.java

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
import org.junit.Test;
2-
import static org.assertj.core.api.Assertions.assertThat;
1+
import org.junit.jupiter.api.DisplayName;
2+
import org.junit.jupiter.api.Tag;
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.assertj.core.api.Assertions.*;
36

47
public class AnnalynsInfiltrationTest {
8+
59
@Test
10+
@Tag("task:1")
11+
@DisplayName("The canFastAttack method returns false when knight is awake")
612
public void cannot_execute_fast_attack_if_knight_is_awake() {
713
boolean knightIsAwake = true;
814
assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isFalse();
915
}
1016

1117
@Test
18+
@Tag("task:1")
19+
@DisplayName("The canFastAttack method returns true when knight is sleeping")
1220
public void can_execute_fast_attack_if_knight_is_sleeping() {
1321
boolean knightIsAwake = false;
1422
assertThat(AnnalynsInfiltration.canFastAttack(knightIsAwake)).isTrue();
1523
}
1624

1725
@Test
26+
@Tag("task:2")
27+
@DisplayName("The canSpy method returns false when everyone is sleeping")
1828
public void cannot_spy_if_everyone_is_sleeping() {
1929
boolean knightIsAwake = false;
2030
boolean archerIsAwake = false;
@@ -23,6 +33,8 @@ public void cannot_spy_if_everyone_is_sleeping() {
2333
}
2434

2535
@Test
36+
@Tag("task:2")
37+
@DisplayName("The canSpy method returns true when everyone but knight is sleeping")
2638
public void can_spy_if_everyone_but_knight_is_sleeping() {
2739
boolean knightIsAwake = true;
2840
boolean archerIsAwake = false;
@@ -31,6 +43,8 @@ public void can_spy_if_everyone_but_knight_is_sleeping() {
3143
}
3244

3345
@Test
46+
@Tag("task:2")
47+
@DisplayName("The canSpy method returns true when everyone but archer is sleeping")
3448
public void can_spy_if_everyone_but_archer_is_sleeping() {
3549
boolean knightIsAwake = false;
3650
boolean archerIsAwake = true;
@@ -39,6 +53,8 @@ public void can_spy_if_everyone_but_archer_is_sleeping() {
3953
}
4054

4155
@Test
56+
@Tag("task:2")
57+
@DisplayName("The canSpy method returns true when everyone but prisoner is sleeping")
4258
public void can_spy_if_everyone_but_prisoner_is_sleeping() {
4359
boolean knightIsAwake = false;
4460
boolean archerIsAwake = false;
@@ -47,6 +63,8 @@ public void can_spy_if_everyone_but_prisoner_is_sleeping() {
4763
}
4864

4965
@Test
66+
@Tag("task:2")
67+
@DisplayName("The canSpy method returns true when only knight is sleeping")
5068
public void can_spy_if_only_knight_is_sleeping() {
5169
boolean knightIsAwake = false;
5270
boolean archerIsAwake = true;
@@ -55,6 +73,8 @@ public void can_spy_if_only_knight_is_sleeping() {
5573
}
5674

5775
@Test
76+
@Tag("task:2")
77+
@DisplayName("The canSpy method returns true when only archer is sleeping")
5878
public void can_spy_if_only_archer_is_sleeping() {
5979
boolean knightIsAwake = true;
6080
boolean archerIsAwake = false;
@@ -63,6 +83,8 @@ public void can_spy_if_only_archer_is_sleeping() {
6383
}
6484

6585
@Test
86+
@Tag("task:2")
87+
@DisplayName("The canSpy method returns true when only prisoner is sleeping")
6688
public void can_spy_if_only_prisoner_is_sleeping() {
6789
boolean knightIsAwake = true;
6890
boolean archerIsAwake = true;
@@ -71,6 +93,8 @@ public void can_spy_if_only_prisoner_is_sleeping() {
7193
}
7294

7395
@Test
96+
@Tag("task:2")
97+
@DisplayName("The canSpy method returns true when everyone is awake")
7498
public void can_spy_if_everyone_is_awake() {
7599
boolean knightIsAwake = true;
76100
boolean archerIsAwake = true;
@@ -79,34 +103,44 @@ public void can_spy_if_everyone_is_awake() {
79103
}
80104

81105
@Test
106+
@Tag("task:3")
107+
@DisplayName("The canSignalPrisoner method returns true when prisoner is awake and archer is sleeping")
82108
public void can_signal_prisoner_if_archer_is_sleeping_and_prisoner_is_awake() {
83109
boolean archerIsAwake = false;
84110
boolean prisonerIsAwake = true;
85111
assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isTrue();
86112
}
87113

88114
@Test
115+
@Tag("task:3")
116+
@DisplayName("The canSignalPrisoner method returns false when prisoner is sleeping and archer is awake")
89117
public void cannot_signal_prisoner_if_archer_is_awake_and_prisoner_is_sleeping() {
90118
boolean archerIsAwake = true;
91119
boolean prisonerIsAwake = false;
92120
assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse();
93121
}
94122

95123
@Test
124+
@Tag("task:3")
125+
@DisplayName("The canSignalPrisoner method returns false when both prisoner and archer are sleeping")
96126
public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_sleeping() {
97127
boolean archerIsAwake = false;
98128
boolean prisonerIsAwake = false;
99129
assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse();
100130
}
101131

102132
@Test
133+
@Tag("task:3")
134+
@DisplayName("The canSignalPrisoner method returns false when both prisoner and archer are awake")
103135
public void cannot_signal_prisoner_if_archer_and_prisoner_are_both_awake() {
104136
boolean archerIsAwake = true;
105137
boolean prisonerIsAwake = true;
106138
assertThat(AnnalynsInfiltration.canSignalPrisoner(archerIsAwake, prisonerIsAwake)).isFalse();
107139
}
108140

109141
@Test
142+
@Tag("task:4")
143+
@DisplayName("The canFreePrisoner method returns false when everyone is awake and pet dog is present")
110144
public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present() {
111145
boolean knightIsAwake = true;
112146
boolean archerIsAwake = true;
@@ -117,6 +151,8 @@ public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_present(
117151
}
118152

119153
@Test
154+
@Tag("task:4")
155+
@DisplayName("The canFreePrisoner method returns false when everyone is awake and pet dog is absent")
120156
public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent() {
121157
boolean knightIsAwake = true;
122158
boolean archerIsAwake = true;
@@ -127,6 +163,8 @@ public void cannot_release_prisoner_if_everyone_is_awake_and_pet_dog_is_absent()
127163
}
128164

129165
@Test
166+
@Tag("task:4")
167+
@DisplayName("The canFreePrisoner method returns true when everyone is sleeping and pet dog is present")
130168
public void can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present() {
131169
boolean knightIsAwake = false;
132170
boolean archerIsAwake = false;
@@ -137,6 +175,8 @@ public void can_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_present()
137175
}
138176

139177
@Test
178+
@Tag("task:4")
179+
@DisplayName("The canFreePrisoner method returns false when everyone is sleeping and pet dog is absent")
140180
public void cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent() {
141181
boolean knightIsAwake = false;
142182
boolean archerIsAwake = false;
@@ -147,6 +187,8 @@ public void cannot_release_prisoner_if_everyone_is_asleep_and_pet_dog_is_absent(
147187
}
148188

149189
@Test
190+
@Tag("task:4")
191+
@DisplayName("The canFreePrisoner method returns true when only prisoner is awake and pet dog is present")
150192
public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_present() {
151193
boolean knightIsAwake = false;
152194
boolean archerIsAwake = false;
@@ -157,6 +199,8 @@ public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_presen
157199
}
158200

159201
@Test
202+
@Tag("task:4")
203+
@DisplayName("The canFreePrisoner method returns true when only prisoner is awake and pet dog is absent")
160204
public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent() {
161205
boolean knightIsAwake = false;
162206
boolean archerIsAwake = false;
@@ -167,6 +211,8 @@ public void can_release_prisoner_if_only_prisoner_is_awake_and_pet_dog_is_absent
167211
}
168212

169213
@Test
214+
@Tag("task:4")
215+
@DisplayName("The canFreePrisoner method returns false when only archer is awake and pet dog is present")
170216
public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_present() {
171217
boolean knightIsAwake = false;
172218
boolean archerIsAwake = true;
@@ -177,6 +223,8 @@ public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_prese
177223
}
178224

179225
@Test
226+
@Tag("task:4")
227+
@DisplayName("The canFreePrisoner method returns false when only archer is awake and pet dog is absent")
180228
public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absent() {
181229
boolean knightIsAwake = false;
182230
boolean archerIsAwake = true;
@@ -187,6 +235,8 @@ public void cannot_release_prisoner_if_only_archer_is_awake_and_pet_dog_is_absen
187235
}
188236

189237
@Test
238+
@Tag("task:4")
239+
@DisplayName("The canFreePrisoner method returns true when only knight is awake and pet dog is present")
190240
public void can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present() {
191241
boolean knightIsAwake = true;
192242
boolean archerIsAwake = false;
@@ -197,6 +247,8 @@ public void can_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_present(
197247
}
198248

199249
@Test
250+
@Tag("task:4")
251+
@DisplayName("The canFreePrisoner method returns false when only knight is awake and pet dog is absent")
200252
public void cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absent() {
201253
boolean knightIsAwake = true;
202254
boolean archerIsAwake = false;
@@ -207,6 +259,8 @@ public void cannot_release_prisoner_if_only_knight_is_awake_and_pet_dog_is_absen
207259
}
208260

209261
@Test
262+
@Tag("task:4")
263+
@DisplayName("The canFreePrisoner method returns false when only knight is sleeping and pet dog is present")
210264
public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_present() {
211265
boolean knightIsAwake = false;
212266
boolean archerIsAwake = true;
@@ -217,6 +271,8 @@ public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_pres
217271
}
218272

219273
@Test
274+
@Tag("task:4")
275+
@DisplayName("The canFreePrisoner method returns false when only knight is sleeping and pet dog is absent")
220276
public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_absent() {
221277
boolean knightIsAwake = false;
222278
boolean archerIsAwake = true;
@@ -227,6 +283,8 @@ public void cannot_release_prisoner_if_only_knight_is_asleep_and_pet_dog_is_abse
227283
}
228284

229285
@Test
286+
@Tag("task:4")
287+
@DisplayName("The canFreePrisoner method returns true when only archer is sleeping and pet dog is present")
230288
public void can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present() {
231289
boolean knightIsAwake = true;
232290
boolean archerIsAwake = false;
@@ -237,6 +295,8 @@ public void can_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_present
237295
}
238296

239297
@Test
298+
@Tag("task:4")
299+
@DisplayName("The canFreePrisoner method returns false when only archer is sleeping and pet dog is absent")
240300
public void cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_absent() {
241301
boolean knightIsAwake = true;
242302
boolean archerIsAwake = false;
@@ -247,6 +307,8 @@ public void cannot_release_prisoner_if_only_archer_is_asleep_and_pet_dog_is_abse
247307
}
248308

249309
@Test
310+
@Tag("task:4")
311+
@DisplayName("The canFreePrisoner method returns false when only prisoner is sleeping and pet dog is present")
250312
public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_present() {
251313
boolean knightIsAwake = true;
252314
boolean archerIsAwake = true;
@@ -257,6 +319,8 @@ public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_pr
257319
}
258320

259321
@Test
322+
@Tag("task:4")
323+
@DisplayName("The canFreePrisoner method returns false when only prisoner is sleeping and pet dog is absent")
260324
public void cannot_release_prisoner_if_only_prisoner_is_asleep_and_pet_dog_is_absent() {
261325
boolean knightIsAwake = true;
262326
boolean archerIsAwake = true;

0 commit comments

Comments
 (0)