On Github ollyjshaw / ttd_talk
Created by Olly Shaw (Team 6)
About me: Lead dev on team 6
Target audience: Developers
Unit Testing all the classes in the codebase?
Using tools like JUnit?
Using Mocks?
Using BDD?
Write a failing test
Write the code to make that test pass
Refactor to make the code cleaner
The game consists of 10 frames as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.
A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.)
A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled.
In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
public class Frame{ public boolean isComplete(){ //Some code here } public int calculateFrameScore(Frame next, Frame nextPlusOne){ //Some code here } public totalKnockedDownThisFrame(){ //Some code here } }
Test units of behaviour
Don't test units of Code
It's what Kent Beck was doing!
Don't mock what you don't own!
A Dummy class is a mock
"Wrapping your third party libraries in objects, and then using those objects in your code (rather than the library directly) is just good practice."
Eric Smith 8th Light
public class MockFrame implements Frame{ public boolean isComplete(){ return true; //I'm always complete! } }