Lab 2 : Mocking and Inheritance
Introduction
In this lab we will start with the refactored version of the simulator that we worked last time - with generics added.
Create a new project based on the latest simulator code
creatures.zip.
Mocking
Add Mockito library to the project build path.
- Download mockito library mockito-all-1.9.5.jar
- Create a new directory in your project called
lib
- Copy there the downloaded mockito jar file
- Right click the jar file and select
Build Path -> Add to build path
Exercise 1: Bouncing Creature Fix
Launch the simulator using the
Launcher
class and try to find the wrong behavior and fix it. Once you are done, write a unit test that verifies that your fix works.
Exercise 2: Smart Creature test
How would you test the emerging behavior of the
SmartCreature
?
Inheritance
The goal is to refactor the creature simulator according to following class diagram
to top