-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilityFactorialJUnitTest.java
More file actions
42 lines (34 loc) · 1017 Bytes
/
UtilityFactorialJUnitTest.java
File metadata and controls
42 lines (34 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package unittesting;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static unittesting.UtilityFactorial.factorial;
/**
* Created by mwypych on 01.06.17.
*/
public class UtilityFactorialJUnitTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test(expected = IllegalArgumentException.class)
public void factorialOfNegativeThrowsAnException__1() {
factorial(-20);
}
@Test
public void factorialOfNegativeThrowsAnException__2() {
thrown.expect(IllegalArgumentException.class);
factorial(-20);
}
@Test
public void factorialOfZeroIsOne() {
assertEquals("factorial(0)", 1, factorial(0));
}
@Test
public void factorialOfOneIsOne() {
assertEquals("factorial(1)", 1, factorial(1));
}
@Test
public void factorialOfNineIs362880() {
assertEquals("factorial(9)", 362880, factorial(9));
}
}