22import org .junit .Ignore ;
33import org .junit .Test ;
44
5+ import static org .assertj .core .api .Assertions .*;
6+
57public class RemoteControlCarTest {
68 @ Test
79 public void buy_new_car_returns_instance () {
810 RemoteControlCar car = RemoteControlCar .buy ();
9- Assert . assertNotNull (car );
11+ assertThat (car ). isNotNull ( );
1012 }
1113
1214 @ Ignore ("Remove to run test" )
1315 @ Test
1416 public void buy_new_car_returns_new_car_each_time () {
1517 RemoteControlCar car1 = RemoteControlCar .buy ();
1618 RemoteControlCar car2 = RemoteControlCar .buy ();
17- Assert . assertNotSame (car2 , car1 );
19+ assertThat ( car1 ). isNotEqualTo (car2 );
1820 }
1921
2022 @ Ignore ("Remove to run test" )
2123 @ Test
2224 public void new_car_distance_display () {
2325 RemoteControlCar car = new RemoteControlCar ();
24- Assert . assertEquals ( "Driven 0 meters" , car . distanceDisplay () );
26+ assertThat ( car . distanceDisplay ()). isEqualTo ( "Driven 0 meters" );
2527 }
2628
2729 @ Ignore ("Remove to run test" )
2830 @ Test
2931 public void new_car_battery_display () {
3032 RemoteControlCar car = new RemoteControlCar ();
31- Assert . assertEquals ( "Battery at 100%" , car . batteryDisplay () );
33+ assertThat ( car . batteryDisplay ()). isEqualTo ( "Battery at 100%" );
3234 }
3335
3436 @ Ignore ("Remove to run test" )
3537 @ Test
3638 public void distance_display_after_driving_once () {
3739 RemoteControlCar car = new RemoteControlCar ();
3840 car .drive ();
39- Assert . assertEquals ( "Driven 20 meters" , car . distanceDisplay () );
41+ assertThat ( car . distanceDisplay ()). isEqualTo ( "Driven 20 meters" );
4042 }
4143
4244 @ Ignore ("Remove to run test" )
@@ -48,15 +50,16 @@ public void distance_display_after_driving_multiple_times() {
4850 car .drive ();
4951 }
5052
51- Assert . assertEquals ( "Driven 340 meters" , car . distanceDisplay () );
53+ assertThat ( car . distanceDisplay ()). isEqualTo ( "Driven 340 meters" );
5254 }
5355
5456 @ Ignore ("Remove to run test" )
5557 @ Test
5658 public void battery_display_after_driving_once () {
5759 RemoteControlCar car = new RemoteControlCar ();
5860 car .drive ();
59- Assert .assertEquals ("Battery at 99%" , car .batteryDisplay ());
61+
62+ assertThat (car .batteryDisplay ()).isEqualTo ("Battery at 99%" );
6063 }
6164
6265 @ Ignore ("Remove to run test" )
@@ -68,7 +71,7 @@ public void battery_display_after_driving_multiple_times() {
6871 car .drive ();
6972 }
7073
71- Assert . assertEquals ( "Battery at 77%" , car . batteryDisplay () );
74+ assertThat ( car . batteryDisplay ()). isEqualTo ( "Battery at 77%" );
7275 }
7376
7477 @ Ignore ("Remove to run test" )
@@ -84,7 +87,7 @@ public void battery_display_when_battery_empty() {
8487 // Attempt to drive one more time (should not work)
8588 car .drive ();
8689
87- Assert . assertEquals ( "Battery empty" , car . batteryDisplay () );
90+ assertThat ( car . batteryDisplay ()). isEqualTo ( "Battery empty" );
8891 }
8992
9093 @ Ignore ("Remove to run test" )
@@ -100,6 +103,6 @@ public void distance_display_when_battery_empty() {
100103 // Attempt to drive one more time (should not work)
101104 car .drive ();
102105
103- Assert . assertEquals ( "Driven 2000 meters" , car . distanceDisplay () );
106+ assertThat ( car . distanceDisplay ()). isEqualTo ( "Driven 2000 meters" );
104107 }
105108}
0 commit comments