Skip to content

Commit add44e0

Browse files
committed
Simple-linked-list: use JUnit's @rule feature
1 parent cb879d3 commit add44e0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎exercises/simple-linked-list/src/test/java/SimpleLinkedListTest.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import org.junit.Ignore;
22
import org.junit.Test;
3+
import org.junit.Rule;
4+
import org.junit.rules.ExpectedException;
35

46
import java.util.NoSuchElementException;
57

@@ -8,7 +10,9 @@
810

911
public class SimpleLinkedListTest {
1012

11-
13+
@Rule
14+
public ExpectedException thrown = ExpectedException.none();
15+
1216
@Test
1317
public void aNewListIsEmpty() {
1418
SimpleLinkedList list = new SimpleLinkedList();
@@ -24,8 +28,9 @@ public void canCreateFromArray() {
2428
}
2529

2630
@Ignore
27-
@Test(expected = NoSuchElementException.class)
31+
@Test
2832
public void popOnEmptyListWillThrow() {
33+
thrown.expect(NoSuchElementException.class);
2934
SimpleLinkedList list = new SimpleLinkedList();
3035
list.pop();
3136
}

0 commit comments

Comments
 (0)