Skip to content

Commit 30ff775

Browse files
authored
Introduce assertj in resistor-color exercise (exercism#1984)
* Changing ResistorColor unit tests to use AssertJ. * Adjusting assertj assertion to be more readable. * Fixing style check violation.
1 parent d689a58 commit 30ff775

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import org.junit.Before;
22
import org.junit.Test;
33
import org.junit.Ignore;
4-
5-
import static org.junit.Assert.assertArrayEquals;
6-
import static org.junit.Assert.assertEquals;
4+
import static org.assertj.core.api.Assertions.assertThat;
75

86
public class ResistorColorTest {
97

@@ -16,36 +14,26 @@ public void setup() {
1614

1715
@Test
1816
public void testBlackColorCode() {
19-
String input = "black";
20-
int expected = 0;
21-
22-
assertEquals(expected, resistorColor.colorCode(input));
17+
assertThat(resistorColor.colorCode("black")).isEqualTo(0);
2318
}
2419

2520
@Ignore("Remove to run test")
2621
@Test
2722
public void testWhiteColorCode() {
28-
String input = "white";
29-
int expected = 9;
30-
31-
assertEquals(expected, resistorColor.colorCode(input));
23+
assertThat(resistorColor.colorCode("white")).isEqualTo(9);
3224
}
3325

3426
@Ignore("Remove to run test")
3527
@Test
3628
public void testOrangeColorCode() {
37-
String input = "orange";
38-
int expected = 3;
39-
40-
assertEquals(expected, resistorColor.colorCode(input));
29+
assertThat(resistorColor.colorCode("orange")).isEqualTo(3);
4130
}
4231

4332
@Ignore("Remove to run test")
4433
@Test
4534
public void testColors() {
46-
String[] expected = {"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"};
47-
48-
assertArrayEquals(expected, resistorColor.colors());
35+
assertThat(resistorColor.colors()).containsExactly(
36+
"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"
37+
);
4938
}
50-
5139
}

0 commit comments

Comments
 (0)