forked from terryyin/com.happyprog.tdgotchi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on passing and failing tests, update observer from junit subscriber
- Loading branch information
Sebastian Hermida
committed
Apr 2, 2011
1 parent
10faf0c
commit 2a21a08
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/com/happyprog/tdgotchi/controller/JUnitTestSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.happyprog.tdgotchi.controller; | ||
|
||
public class JUnitTestSubscriber implements TestSubscriber { | ||
|
||
private TestObserver observer; | ||
|
||
@Override | ||
public void subscribe(TestObserver observer) { | ||
this.observer = observer; | ||
} | ||
|
||
public void onPassingTest() { | ||
observer.onPassingTest(); | ||
} | ||
|
||
public void onFailingTest() { | ||
observer.onFailingTest(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/com/happyprog/tdgotchi/controller/JUnitTestSubscriberTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.happyprog.tdgotchi.controller; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class JUnitTestSubscriberTest { | ||
|
||
private TestObserver observer; | ||
private JUnitTestSubscriber subscriber; | ||
|
||
@Before | ||
public void before() { | ||
observer = mock(TestObserver.class); | ||
subscriber = new JUnitTestSubscriber(); | ||
|
||
subscriber.subscribe(observer); | ||
} | ||
|
||
@Test | ||
public void onPassingTest_updateObserver() throws Exception { | ||
subscriber.onPassingTest(); | ||
|
||
verify(observer).onPassingTest(); | ||
} | ||
|
||
@Test | ||
public void onFailingTest_updateObserver() throws Exception { | ||
subscriber.onFailingTest(); | ||
|
||
verify(observer).onFailingTest(); | ||
} | ||
} |