File tree Expand file tree Collapse file tree
exercises/triangle/src/test/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import org .junit .Test ;
22import org .junit .Ignore ;
3+ import org .junit .rules .TestWatcher ;
34
45import static org .junit .Assert .assertEquals ;
56
67public 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}
You can’t perform that action at this time.
0 commit comments