Skip to content

Commit

Permalink
week4 tune
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 11, 2019
1 parent d6eb9fb commit 90e4114
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 49 deletions.
14 changes: 4 additions & 10 deletions junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ $ make

## syllabus
### week3
[onlyTest](onlyTest)

#### [onlyTest](onlyTest)
Only JUint test

[testCode](testCode)

#### [testCode](testCode)
Simple assert

### week4
[beforeAfter](beforeAfter)

#### [beforeAfter](beforeAfter)
Show execution path of before and after annotation

[Stack](Stack)

#### [Stack](Stack)
Use stack example show why use before and after annotation
2 changes: 1 addition & 1 deletion junit/beforeAfter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ all: compile

compile:
mkdir -p bin
javac testcase/TestJunit.java testcase/TestRunner.java -d bin
javac testcase/TestBeforeAfter.java testcase/TestRunner.java -d bin

test:
cd bin ; java TestRunner
Expand Down
35 changes: 0 additions & 35 deletions junit/beforeAfter/testcase/TestJunit.java

This file was deleted.

2 changes: 1 addition & 1 deletion junit/beforeAfter/testcase/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class TestRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestJunit.class);
Result result = JUnitCore.runClasses(TestBeforeAfter.class);
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
Expand Down
4 changes: 2 additions & 2 deletions junit/stack/src/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public Stack() {
size = 0;
}

public int size(){
public int size() {
return this.size;
}

Expand All @@ -26,7 +26,7 @@ public void push(Object obj) {

public Object pop() throws Exception {
if (head == null) {
throw new Exception();
throw new Exception("Pop an empty stack");
}
Object tmp = head.data;
head = head.next;
Expand Down
4 changes: 4 additions & 0 deletions junit/stack/testcase/TestStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ public static void beforeClass() {

@Before
public void before() {
// initial some node in stack structure
stack.push(3);
stack.push(2);
}

@After
public void after() throws Exception {
// clean all node in stack
while (stack.size() != 0) {
stack.pop();
}
// try to create some exception
//stack.pop();
}

@AfterClass
Expand Down

0 comments on commit 90e4114

Please sign in to comment.