Skip to content

Instantly share code, notes, and snippets.

@petergtz
Created April 22, 2018 19:07
Show Gist options
  • Save petergtz/e1bae6c1751b789ae8641866944962a4 to your computer and use it in GitHub Desktop.
Save petergtz/e1bae6c1751b789ae8641866944962a4 to your computer and use it in GitHub Desktop.
// Interface:
type PhoneBook interface {
GetPhoneNumber(name string) string
}
// Test:
// creating the mock
phoneBook := NewMockPhoneBook()
// stubbing:
When(phoneBook.GetPhoneNumber("Tom")).ThenReturn("345-123-789")
When(phoneBook.GetPhoneNumber("Dan")).ThenReturn("123-456-000")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment