-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathGHCommitPointerTest.java
More file actions
31 lines (25 loc) · 971 Bytes
/
GHCommitPointerTest.java
File metadata and controls
31 lines (25 loc) · 971 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
package org.kohsuke.github;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
public class GHCommitPointerTest {
//week8 failing test:
//test the null value
// @Test
// public void nullRepoNpe() throws Exception {
// GHCommitPointer pointer = new GHCommitPointer(); //new object value is null
//
// throws NPE because repository is null.
// pointer.getCommit();
// }
//week9 fixed test
//test the IOException, which is more controllable
@Test
public void nullRepoNpe() {
GHCommitPointer pointer = new GHCommitPointer();
//expect throw IOException, test fail otherwise
IOException ex = Assert.assertThrows(IOException.class, pointer::getCommit); //method reference
//continue to test if error message also contains "repository is null", test fail otherwise
Assert.assertTrue(ex.getMessage().contains("repository is null"));
}
}