Skip to content

Commit d3c4e6b

Browse files
author
Kay Hudson
committed
Add messages for test expectations.
1 parent da51635 commit d3c4e6b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/test/java/StackTestCase.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,38 @@
44

55
import com.galvanize.Stack;
66

7-
public class StackTestCase {
7+
class StackTestCase {
88

99
@Test()
1010
@DisplayName("Stack.push() adds a new object")
11-
public void testStackPush() {
11+
void testStackPush() {
1212
Stack newStack = new Stack();
13-
assertEquals(0, newStack.count());
13+
assertEquals(0, newStack.count(),"Stack should be empty on initialization");
1414
newStack.push(100);
15-
assertEquals(1, newStack.count());
16-
assertFalse(newStack.empty);
15+
assertEquals(1, newStack.count(), "Stack should contain only 1 object.");
16+
assertFalse(newStack.empty, "Stack should not be empty.");
1717
}
1818

1919
@Test
2020
@DisplayName("Stack.pop() removes and returns last item added.")
21-
public void testStackPopRemovesAndReturnsLastItemIn() {
21+
void testStackPopRemovesAndReturnsLastItemIn() {
2222
Stack newStack = new Stack();
2323
newStack.push(1);
2424
newStack.push(2);
2525
newStack.push(3);
26-
assertEquals(3, newStack.count());
26+
assertEquals(3, newStack.count(), "Stack should contain 3 objects.");
2727
Object item = newStack.pop();
28-
assertEquals(2, newStack.count());
29-
assertEquals(3, item);
28+
assertEquals(2, newStack.count(), "Stack should contain only 2 items after .pop()");
29+
assertEquals(3, item, "The removed object should have a value of 3");
3030
}
3131

3232
@Test
3333
@DisplayName("Stack.peek() returns the last item added without removing it.")
34-
public void testStackPeek() {
34+
void testStackPeek() {
3535
Stack newStack = new Stack();
3636
newStack.push("sock");
3737
newStack.push("shoe");
38-
assertEquals("shoe", newStack.peek());
38+
assertEquals("shoe", newStack.peek(), "The last object should be 'shoe'.");
39+
assertEquals(2, newStack.count(), "The stack size should be unchanged after peek().");
3940
}
4041
}

0 commit comments

Comments
 (0)