Created
August 1, 2011 23:58
-
-
Save toddlipcon/1119278 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Foo { | |
| public void dog() { | |
| print("woof"); | |
| } | |
| public void cat() { | |
| print("meow"); | |
| } | |
| public void both() { | |
| dog(); cat(); | |
| } | |
| } | |
| class Test { | |
| public void test() { | |
| Foo foo = new Foo(); | |
| Foo mySpy = spy(foo); | |
| doThrow(new RTE("x")).when(mySpy).cat(); | |
| foo.cat(); // meows | |
| foo.dog(); // barks | |
| foo.both(); // does both | |
| mySpy.both(); // does both | |
| mySpy.cat(); // throws | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment