Skip to content

Commit eca5f62

Browse files
authored
Update remote control competition to use test runner v3 features (#2503)
* Update remote control competition to use test runner v3 features (#2500) * added util imports * updated display name on task 3 test
1 parent c173950 commit eca5f62

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

exercises/concept/remote-control-competition/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/remote-control-competition/src/test/java/RemoteControlCarTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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 java.util.ArrayList;
46
import java.util.List;
@@ -7,18 +9,24 @@
79

810
public class RemoteControlCarTest {
911
@Test
12+
@Tag("task:1")
13+
@DisplayName("The ProductionRemoteControlCar is an instance of the RemoteControlCar interface")
1014
public void productionRccIsRemoteControlCar() {
1115
ProductionRemoteControlCar productionCar = new ProductionRemoteControlCar();
1216
assertThat(productionCar instanceof RemoteControlCar).isTrue();
1317
}
1418

1519
@Test
20+
@Tag("task:1")
21+
@DisplayName("The ExperimentalRemoteControlCar is an instance of the RemoteControlCar interface")
1622
public void experimentalRccIsRemoteControlCar() {
1723
ExperimentalRemoteControlCar experimentalCar = new ExperimentalRemoteControlCar();
1824
assertThat(experimentalCar instanceof RemoteControlCar).isTrue();
1925
}
2026

2127
@Test
28+
@Tag("task:2")
29+
@DisplayName("The getDistanceTravelled method of the ProductionRemoteControlCar returns 10 after driving once")
2230
public void productionCarTravels10UnitsPerDrive() {
2331
ProductionRemoteControlCar car = new ProductionRemoteControlCar();
2432
assertThat(car.getDistanceTravelled()).isEqualTo(0);
@@ -27,6 +35,8 @@ public void productionCarTravels10UnitsPerDrive() {
2735
}
2836

2937
@Test
38+
@Tag("task:2")
39+
@DisplayName("The getDistanceTravelled method of the ExperimentalRemoteControlCar returns 20 after driving once")
3040
public void experimentalCarTravels20UnitsPerDrive() {
3141
ExperimentalRemoteControlCar car = new ExperimentalRemoteControlCar();
3242
assertThat(car.getDistanceTravelled()).isEqualTo(0);
@@ -35,6 +45,8 @@ public void experimentalCarTravels20UnitsPerDrive() {
3545
}
3646

3747
@Test
48+
@Tag("task:3")
49+
@DisplayName("The TestTrack.race method uses the drive method on the remote control car")
3850
public void race() {
3951
ProductionRemoteControlCar productionCar = new ProductionRemoteControlCar();
4052
ExperimentalRemoteControlCar experimentalCar = new ExperimentalRemoteControlCar();
@@ -46,6 +58,8 @@ public void race() {
4658
}
4759

4860
@Test
61+
@Tag("task:4")
62+
@DisplayName("The ProductionRemoteControlCar implements the Comparable interface")
4963
public void ensureCarsAreComparable() {
5064
assertThat(Comparable.class).isAssignableFrom(ProductionRemoteControlCar.class);
5165
}
@@ -57,6 +71,8 @@ private static ProductionRemoteControlCar getCarWithVictories(int numberOfVictor
5771
}
5872

5973
@Test
74+
@Tag("task:4")
75+
@DisplayName("The getRankedCars returns a list of two cars sorted by number of victories")
6076
public void rankTwoCars() {
6177
List<ProductionRemoteControlCar> unsortedCars = new ArrayList<>() {
6278
{
@@ -70,6 +86,8 @@ public void rankTwoCars() {
7086
}
7187

7288
@Test
89+
@Tag("task:4")
90+
@DisplayName("The getRankedCars returns a list of multiple cars sorted by number of victories")
7391
public void rankManyCars() {
7492
List<ProductionRemoteControlCar> unsortedCars = new ArrayList<>() {
7593
{

0 commit comments

Comments
 (0)