- Objective:
- To create tests that ensure expected behavior of each class:
- Cat
- Dog
- AnimalFactory
- CatHouse
- DogHouse
- To create tests that ensure expected behavior of each class:
- Purpose:
- To establish familiarity with Test-Driven-Development (TDD) practices.
- Getting context:
- Click here to gain more familiarity with TDD-structured programming.
- Begin by opening the project via its
pom.xml
with IntelliJ. - Continue by opening the
test.java.rocks.zipcodewilmington
package and completing each of theTODO
s.
- Create tests for
void setName(String name)
- ensure that when
.setName
is invoked on an instance ofCat
, thename
field is being set to the respective value.
- ensure that when
- Create tests for
setBirthDate(Date birthDate)
- ensure that when
.setBirthDate
is invoked on an instance ofCat
, thebirthDate
field is being set to the respective value.
- ensure that when
- Create tests for
String speak()
- ensure that when
.speak
is invoked on an instance ofCat
, the value"meow!"
is returned.
- ensure that when
- Create tests for
void eat(Food food)
- ensure that when
.eat
is invoked on an instance ofCat
, thenumberOfMealsEaten
is increased by 1.
- ensure that when
- Create tests for
Integer getId()
- ensure that when
.getId
is invoked on an instance ofCat
, the respectiveid
value is returned.
- ensure that when
- Create test to check Animal inheritance; google search
java instanceof keyword
- ensure that a
Cat
is aninstanceof
an Animal
- ensure that a
- Create test to check Mammal inheritance; google search
java instanceof keyword
- ensure that a
Cat
is aninstanceof
a Mammal
- ensure that a
- Create tests for
void setName(String name)
- ensure that when
.setName
is invoked on an instance ofDog
, thename
field is being set to the respective value.
- ensure that when
- Create tests for
setBirthDate(Date birthDate)
- ensure that when
.setBirthDate
is invoked on an instance ofDog
, thebirthDate
field is being set to the respective value.
- ensure that when
- Create tests for
String speak()
- ensure that when
.speak
is invoked on an instance ofDog
, the value"bark!"
is returned.
- ensure that when
- Create tests for
void eat(Food food)
- ensure that when
.eat
is invoked on an instance ofDog
, thenumberOfMealsEaten
is increased by 1.
- ensure that when
- Create tests for
Integer getId()
- ensure that when
.getId
is invoked on an instance ofDog
, the respectiveid
value is returned.
- ensure that when
- Create test to check Animal inheritance; google search
java instanceof keyword
- ensure that a
Dog
is aninstanceof
an Animal
- ensure that a
- Create test to check Mammal inheritance; google search
java instanceof keyword
- ensure that a
Dog
is aninstanceof
an Mammal
- ensure that a
- Create Test for
Animal createDog(String name, Date birthDate)
- ensure that when
.createDog
is invoked onAnimalFactoryTest
aDog
is created with the respectivename
andbirthDate
value.
- ensure that when
- Create Test for
Animal createCat(String name, Date birthDate)
- ensure that when
.createCat
is invoked onAnimalFactoryTest
aDog
is created with the respectivename
andbirthDate
value.
- ensure that when
- Create tests for
void add(Cat cat)
- ensure that when
.add
is invoked on theCatHouse
, a respectiveCat
object can be retrieved from the house.
- ensure that when
- Create tests for
void remove(Cat cat)
- ensure that when
.remove
is invoked on theCatHouse
, a respectiveCat
object can no longer be retrieved from the house.
- ensure that when
- Create tests for
void remove(Integer id)
- ensure that when
.remove
is invoked on theCatHouse
, aCat
object with the respectiveid
can no longer be retrieved from the house.
- ensure that when
- Create tests for
Cat getCatById(Integer id)
- ensure that when
.getCatById
is invoked on theCatHouse
, aCat
with the respectiveid
is returned.
- ensure that when
- Create tests for
Integer getNumberOfCats()
- ensure that when
.getNumberOfCats()
is invoked on theCatHouse
, the respective number ofCat
objects is returned.
- ensure that when
- Create tests for
void add(Dog dog)
- ensure that when
.add
is invoked on theDogHouse
, a respectiveDog
object can be retrieved from the house.
- ensure that when
- Create tests for
void remove(Integer id)
- ensure that when
.remove
is invoked on theDogHouse
, a respectiveDog
object can no longer be retrieved from the house.
- ensure that when
- Create tests for
void remove(Dog dog)
- ensure that when
.remove
is invoked on theDogHouse
, aDog
object with the respectiveid
can no longer be retrieved from the house.
- ensure that when
- Create tests for
Dog getDogById(Integer id)
- ensure that when
.getCatById
is invoked on theDogHouse
, aDog
with the respectiveid
is returned.
- ensure that when
- Create tests for
Integer getNumberOfDogs()
- ensure that when
.getNumberOfDogs()
is invoked on theDogHouse
, the respective number ofDog
objects is returned.
- ensure that when