Skip to content

Instantly share code, notes, and snippets.

@arlandism
Created December 2, 2013 22:09
Show Gist options
  • Select an option

  • Save arlandism/7759985 to your computer and use it in GitHub Desktop.

Select an option

Save arlandism/7759985 to your computer and use it in GitHub Desktop.
Mocks
public class MyPrinter implements MyPrinterInterface(){
@Override
public void printToScreen(String toPrint){
System.out.println(toPrint);
}
}
public class MyPrinterMock implements MyPrinterInterface(){
private LinkedList<String> history = new LinkedList<String>();
@Override
public void printToScreen(String toPrint){
history.push(toPrint);
}
public Boolean lastCallWas(String message){
return history.peek().equals(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment