|
|
@@ -1,11 +1,13 @@
|
|
1
|
1
|
import org.junit.Test;
|
|
2
|
2
|
import org.junit.Ignore;
|
|
|
3
|
+import org.junit.rules.TestWatcher;
|
|
3
|
4
|
|
|
4
|
5
|
import static org.junit.Assert.assertEquals;
|
|
5
|
6
|
|
|
6
|
7
|
public class TriangleTest {
|
|
7
|
8
|
|
|
8
|
|
-
|
|
|
9
|
+ @Rule
|
|
|
10
|
+ public final ExpectedException thrown = ExpectedException.none();
|
|
9
|
11
|
@Test
|
|
10
|
12
|
public void equilateralTriangleHaveEqualSides() throws Exception {
|
|
11
|
13
|
Triangle triangle = new Triangle(2, 2, 2);
|
|
|
@@ -86,32 +88,37 @@ public class TriangleTest {
|
|
86
|
88
|
}
|
|
87
|
89
|
|
|
88
|
90
|
@Ignore
|
|
89
|
|
- @Test(expected = TriangleException.class)
|
|
|
91
|
+ @Test
|
|
90
|
92
|
public void trianglesWithNoSizeAreIllegal() throws Exception {
|
|
|
93
|
+ thrown.expect(TriangleException.class);
|
|
91
|
94
|
new Triangle(0, 0, 0);
|
|
92
|
95
|
}
|
|
93
|
96
|
|
|
94
|
97
|
@Ignore
|
|
95
|
|
- @Test(expected = TriangleException.class)
|
|
|
98
|
+ @Test
|
|
96
|
99
|
public void trianglesWithNegativeSidesAreIllegal() throws Exception {
|
|
|
100
|
+ thrown.expect(TriangleException.class);
|
|
97
|
101
|
new Triangle(3, 4, -5);
|
|
98
|
102
|
}
|
|
99
|
103
|
|
|
100
|
104
|
@Ignore
|
|
101
|
|
- @Test(expected = TriangleException.class)
|
|
|
105
|
+ @Test
|
|
102
|
106
|
public void trianglesViolatingTriangleInequalityAreIllegal() throws Exception {
|
|
|
107
|
+ thrown.expect(TriangleException.class);
|
|
103
|
108
|
new Triangle(1, 1, 3);
|
|
104
|
109
|
}
|
|
105
|
110
|
|
|
106
|
111
|
@Ignore
|
|
107
|
|
- @Test(expected = TriangleException.class)
|
|
|
112
|
+ @Test
|
|
108
|
113
|
public void trianglesViolatingTriangleInequalityAreIllegal2() throws Exception {
|
|
|
114
|
+ thrown.expect(TriangleException.class);
|
|
109
|
115
|
new Triangle(2, 4, 2);
|
|
110
|
116
|
}
|
|
111
|
117
|
|
|
112
|
118
|
@Ignore
|
|
113
|
|
- @Test(expected = TriangleException.class)
|
|
|
119
|
+ @Test
|
|
114
|
120
|
public void trianglesViolatingTriangleInequalityAreIllegal3() throws Exception {
|
|
|
121
|
+ thrown.expect(TriangleException.class);
|
|
115
|
122
|
new Triangle(7, 3, 2);
|
|
116
|
123
|
}
|
|
117
|
124
|
}
|