Skip to content

Commit d00ba4b

Browse files
authored
Fix FootballMatchReportsTest (exercism#2014)
Tests needed to use AssertJ properly. Also switched to the assertThrows method. Fixes exercism#2013
1 parent 2d97a6a commit d00ba4b

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,74 @@
11
import org.junit.Ignore;
22
import org.junit.Test;
33

4-
import static org.assertj.core.api.Assertions.*;
4+
import static org.assertj.core.api.Assertions.assertThat;
5+
import static org.junit.Assert.assertThrows;
56

67
public class FootballMatchReportsTest {
78

89
@Test
910
public void test_goal() {
10-
assertThat(FootballMatchReports.onField(1).contentEquals("goalie"));
11+
assertThat(FootballMatchReports.onField(1)).isEqualTo("goalie");
1112
}
1213

1314
@Test
1415
@Ignore("Remove to run test")
1516
public void test_left_back() {
16-
assertThat(FootballMatchReports.onField(2).contentEquals("left back"));
17+
assertThat(FootballMatchReports.onField(2)).isEqualTo("left back");
1718
}
1819

1920
@Test
2021
@Ignore("Remove to run test")
2122
public void test_right_back() {
22-
assertThat(FootballMatchReports.onField(5).contentEquals("right back"));
23+
assertThat(FootballMatchReports.onField(5)).isEqualTo("right back");
2324
}
2425

2526
@Test
2627
@Ignore("Remove to run test")
2728
public void test_center_back() {
28-
assertThat(FootballMatchReports.onField(3).contentEquals("center back"));
29-
assertThat(FootballMatchReports.onField(4).contentEquals("center back"));
29+
assertThat(FootballMatchReports.onField(3)).isEqualTo("center back");
30+
assertThat(FootballMatchReports.onField(4)).isEqualTo("center back");
3031
}
3132

3233
@Test
3334
@Ignore("Remove to run test")
3435
public void test_midfielder() {
35-
assertThat(FootballMatchReports.onField(6).contentEquals("midfielder"));
36-
assertThat(FootballMatchReports.onField(7).contentEquals("midfielder"));
37-
assertThat(FootballMatchReports.onField(8).contentEquals("midfielder"));
36+
assertThat(FootballMatchReports.onField(6)).isEqualTo("midfielder");
37+
assertThat(FootballMatchReports.onField(7)).isEqualTo("midfielder");
38+
assertThat(FootballMatchReports.onField(8)).isEqualTo("midfielder");
3839
}
3940

4041
@Test
4142
@Ignore("Remove to run test")
4243
public void test_left_wing() {
43-
assertThat(FootballMatchReports.onField(9).contentEquals("left wing"));
44+
assertThat(FootballMatchReports.onField(9)).isEqualTo("left wing");
4445
}
4546

4647
@Test
4748
@Ignore("Remove to run test")
4849
public void test_striker() {
49-
assertThat(FootballMatchReports.onField(10).contentEquals("striker"));
50+
assertThat(FootballMatchReports.onField(10)).isEqualTo("striker");
5051
}
5152

5253
@Test
5354
@Ignore("Remove to run test")
5455
public void test_right_wing() {
55-
assertThat(FootballMatchReports.onField(11).contentEquals("right wing"));
56+
assertThat(FootballMatchReports.onField(11)).isEqualTo("right wing");
5657
}
5758

58-
@Test(expected = IllegalArgumentException.class)
59+
@Test
5960
@Ignore("Remove to run test")
6061
public void test_exception() {
61-
FootballMatchReports.onField(13);
62+
assertThrows(
63+
IllegalArgumentException.class,
64+
() -> FootballMatchReports.onField(13));
6265
}
6366

64-
@Test(expected = IllegalArgumentException.class)
67+
@Test
6568
@Ignore("Remove to run test")
6669
public void test_exception_negative_number() {
67-
FootballMatchReports.onField(-1);
70+
assertThrows(
71+
IllegalArgumentException.class,
72+
() -> FootballMatchReports.onField(-1));
6873
}
6974
}

0 commit comments

Comments
 (0)