title | type | duration | creator |
---|---|---|---|
JUnit Testing Lab |
lab |
1:25 |
James Davis (NYC) |
JUnit Testing
Introduction
Using the code from a previous lab - where we created and worked with an Animal class and a Zoo class - you are going to write tests (that pass) for the code in this "Zoo App". For more context, read the Introduction from the lab we're referring too:
This lab will continue our subclasses lab where we created subclasses of Animals. Instead of storing all of our Animals in an ArrayList, we're going to store all of them in a Zoo class that is a Singleton. If you remember from the lesson, a Singleton is a class where only one instance exists in memory. In addition to giving our Animal objects a new place to live, the Zoo will make sure our Animals only exist once in memory.
In addition, you're going to add a method, makeNoise()
, that returns the sound that animal makes as a String. All this will take place in an Android app, and when the user presses on the Animal in the list, a Toast should pop up with whatever the corresponding Animal's noise ("Roar","Hiss","Meow" etc.).
Exercise
Requirements
The code provided is the solution code from from the "Zoo App". Write tests to make sure:
- The animals make their appropriate sounds
- The animals have their appropriate top speeds
- The Zoo properly adds and removes animals
Bonus
- Create a new animal and write appropriate tests for it
- Create a listview. Write an appropriate test for it
Starter code
The starter code is the solution code to OOP practice lab.
You can use your previous code, if you would like to.
Deliverable
An app with passing tests!