Skip to content

Instantly share code, notes, and snippets.

Created Jul 9, 2016
What would you like to do?
package pet;
class Dog {
private static final String DEFAULT_NAME = "Spot";
private String name;
Dog(String name) {
if (null == name) {
} = name;
String getName() {
return name;
package pet;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.assertEquals;
public class DogTest {
public void whenNullNameProvided_thenNameIsSpot() {
final String expected = "Spot";
final String actual = (new Dog(null)).getName();
assertEquals(expected, actual);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment