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 ;
2
4
3
5
import java .util .ArrayList ;
4
6
import java .util .List ;
7
9
8
10
public class RemoteControlCarTest {
9
11
@ Test
12
+ @ Tag ("task:1" )
13
+ @ DisplayName ("The ProductionRemoteControlCar is an instance of the RemoteControlCar interface" )
10
14
public void productionRccIsRemoteControlCar () {
11
15
ProductionRemoteControlCar productionCar = new ProductionRemoteControlCar ();
12
16
assertThat (productionCar instanceof RemoteControlCar ).isTrue ();
13
17
}
14
18
15
19
@ Test
20
+ @ Tag ("task:1" )
21
+ @ DisplayName ("The ExperimentalRemoteControlCar is an instance of the RemoteControlCar interface" )
16
22
public void experimentalRccIsRemoteControlCar () {
17
23
ExperimentalRemoteControlCar experimentalCar = new ExperimentalRemoteControlCar ();
18
24
assertThat (experimentalCar instanceof RemoteControlCar ).isTrue ();
19
25
}
20
26
21
27
@ Test
28
+ @ Tag ("task:2" )
29
+ @ DisplayName ("The getDistanceTravelled method of the ProductionRemoteControlCar returns 10 after driving once" )
22
30
public void productionCarTravels10UnitsPerDrive () {
23
31
ProductionRemoteControlCar car = new ProductionRemoteControlCar ();
24
32
assertThat (car .getDistanceTravelled ()).isEqualTo (0 );
@@ -27,6 +35,8 @@ public void productionCarTravels10UnitsPerDrive() {
27
35
}
28
36
29
37
@ Test
38
+ @ Tag ("task:2" )
39
+ @ DisplayName ("The getDistanceTravelled method of the ExperimentalRemoteControlCar returns 20 after driving once" )
30
40
public void experimentalCarTravels20UnitsPerDrive () {
31
41
ExperimentalRemoteControlCar car = new ExperimentalRemoteControlCar ();
32
42
assertThat (car .getDistanceTravelled ()).isEqualTo (0 );
@@ -35,6 +45,8 @@ public void experimentalCarTravels20UnitsPerDrive() {
35
45
}
36
46
37
47
@ Test
48
+ @ Tag ("task:3" )
49
+ @ DisplayName ("The TestTrack.race method uses the drive method on the remote control car" )
38
50
public void race () {
39
51
ProductionRemoteControlCar productionCar = new ProductionRemoteControlCar ();
40
52
ExperimentalRemoteControlCar experimentalCar = new ExperimentalRemoteControlCar ();
@@ -46,6 +58,8 @@ public void race() {
46
58
}
47
59
48
60
@ Test
61
+ @ Tag ("task:4" )
62
+ @ DisplayName ("The ProductionRemoteControlCar implements the Comparable interface" )
49
63
public void ensureCarsAreComparable () {
50
64
assertThat (Comparable .class ).isAssignableFrom (ProductionRemoteControlCar .class );
51
65
}
@@ -57,6 +71,8 @@ private static ProductionRemoteControlCar getCarWithVictories(int numberOfVictor
57
71
}
58
72
59
73
@ Test
74
+ @ Tag ("task:4" )
75
+ @ DisplayName ("The getRankedCars returns a list of two cars sorted by number of victories" )
60
76
public void rankTwoCars () {
61
77
List <ProductionRemoteControlCar > unsortedCars = new ArrayList <>() {
62
78
{
@@ -70,6 +86,8 @@ public void rankTwoCars() {
70
86
}
71
87
72
88
@ Test
89
+ @ Tag ("task:4" )
90
+ @ DisplayName ("The getRankedCars returns a list of multiple cars sorted by number of victories" )
73
91
public void rankManyCars () {
74
92
List <ProductionRemoteControlCar > unsortedCars = new ArrayList <>() {
75
93
{
0 commit comments