Skip to content

Instantly share code, notes, and snippets.

@outdooricon
Created August 30, 2011 17:02
Show Gist options
  • Save outdooricon/1181365 to your computer and use it in GitHub Desktop.
Save outdooricon/1181365 to your computer and use it in GitHub Desktop.
example of testing an abstract class with Mockito
// The Abstract Class We Are Testing
public Abstract class Car {
public String getDescription(String color) {
return "sleek "+color+" car";
};
}
// Test Contained in Separate Class Below
Car blueCar = mock(Car.class);
given(blueCar.getDescription(anyString())).willCallRealMethod();
assertThat(blueCar.getDescription("blue"), contains("blue"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment