Skip to content

Commit 63784f3

Browse files
committed
Change JUnit @test expected parameter with ExpectedException @rule in triangle exercise [Fix exercism#268]
1 parent 30b6592 commit 63784f3

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎exercises/triangle/src/test/java/TriangleTest.java‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import org.junit.Test;
22
import org.junit.Ignore;
3+
import org.junit.rules.TestWatcher;
34

45
import static org.junit.Assert.assertEquals;
56

67
public class TriangleTest {
78

8-
9+
@Rule
10+
public final ExpectedException thrown = ExpectedException.none();
911
@Test
1012
public void equilateralTriangleHaveEqualSides() throws Exception {
1113
Triangle triangle = new Triangle(2, 2, 2);
@@ -86,32 +88,37 @@ public void verySmallTrianglesAreLegal() throws Exception {
8688
}
8789

8890
@Ignore
89-
@Test(expected = TriangleException.class)
91+
@Test
9092
public void trianglesWithNoSizeAreIllegal() throws Exception {
93+
thrown.expect(TriangleException.class);
9194
new Triangle(0, 0, 0);
9295
}
9396

9497
@Ignore
95-
@Test(expected = TriangleException.class)
98+
@Test
9699
public void trianglesWithNegativeSidesAreIllegal() throws Exception {
100+
thrown.expect(TriangleException.class);
97101
new Triangle(3, 4, -5);
98102
}
99103

100104
@Ignore
101-
@Test(expected = TriangleException.class)
105+
@Test
102106
public void trianglesViolatingTriangleInequalityAreIllegal() throws Exception {
107+
thrown.expect(TriangleException.class);
103108
new Triangle(1, 1, 3);
104109
}
105110

106111
@Ignore
107-
@Test(expected = TriangleException.class)
112+
@Test
108113
public void trianglesViolatingTriangleInequalityAreIllegal2() throws Exception {
114+
thrown.expect(TriangleException.class);
109115
new Triangle(2, 4, 2);
110116
}
111117

112118
@Ignore
113-
@Test(expected = TriangleException.class)
119+
@Test
114120
public void trianglesViolatingTriangleInequalityAreIllegal3() throws Exception {
121+
thrown.expect(TriangleException.class);
115122
new Triangle(7, 3, 2);
116123
}
117124
}

0 commit comments

Comments
 (0)