Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created August 1, 2011 23:58
Show Gist options
  • Select an option

  • Save toddlipcon/1119278 to your computer and use it in GitHub Desktop.

Select an option

Save toddlipcon/1119278 to your computer and use it in GitHub Desktop.
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