Put the Tests Before the Code
-
Upload
mike-clement -
Category
Software
-
view
198 -
download
0
Transcript of Put the Tests Before the Code
![Page 1: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/1.jpg)
Put the Tests before the Code: Coding the
Right WayMike Clement@mdclement
[email protected]://blog.softwareontheside.com
http://agilecodegames.com
![Page 2: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/2.jpg)
REQUIREMENTS
You will need these files(Windows) to complete the assignment. Details for method constraints are found in these documents and are still a part of the requirements. (If you downloaded the test driver documents before 8/30 12:00pm you will need to re-download them. An error was fixed.)
Part 1 - Construct the Arena (5 points)
Extend the ArenaInterface provided; the arena is simply a collection of fighters, each with a unique nameFor Part 1 only, you may assume all strings passed to the arena's adding method will be of the correct formatFor Part 1 only, you may assume all strings passed to the arena's getting and removing methods will be names already existing in the arenaPart 2 - Let the Battle Begin (8 points)
Extend the FighterInterface provided; details about abilities, stats, and more can be found in the FighterInterfaceFor Part 3, the test driver will not call your useAbility() or regenerate() methods, so it is possible to receive credit for Part 3 without these methods being completeCompletion of Part 1 is required to submit Part 2Part 3 - Fortify the Walls (5 points)
Make adding new fighters to your arena bullet-proofThis involves rejecting any string that is not of the correct format or that would add a duplicate name to the arenaMake getting and removing existing fighters in your arena bullet-proofCompletion of Part 1 is required to submit Part 3Part 4 - Let Me Show You My True Form... (12 points, 4 points per fighter type)
Add functionality to the useAbility() method and the regenerate() method for each fighter typeThe isSimplified() method must return false for each fighter type to be tested to alert the test driver that full testing should occur for that fighter typeCompletion of Part 1 is required to submit Part 4
![Page 3: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/3.jpg)
Clean Code that Works
![Page 4: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/4.jpg)
Plan
Requirements
Design
Coding
Testing
Release
![Page 5: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/5.jpg)
Design
Coding
Testing
![Page 6: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/6.jpg)
![Page 7: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/7.jpg)
Plan
Requirements
Design
Coding
Testing
Release
![Page 8: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/8.jpg)
![Page 9: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/9.jpg)
![Page 10: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/10.jpg)
Design
Coding
Testing
![Page 11: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/11.jpg)
When you actually sit down to write some code, you learn things that you didn’t get from thinking about them in modeling terms…there is a feedback process there that you can only really get at from executing some things and seeing what works
- Martin Fowler
![Page 12: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/12.jpg)
Sample Input
61 21 33 43 54 65 62 32 40 0
4 2 33 45 11 67 88 92 55 73 11 84 66 90 0
Sample Output
CASE 1:1 2 3 4 61 2 3 5 61 2 4 3 5 61 2 4 61 3 2 4 61 3 4 61 3 5 6There are 7 routes from the firestation to streetcorner 6.
CASE 2:1 3 2 5 7 8 9 6 41 3 41 5 2 3 41 5 7 8 9 6 41 6 41 6 9 8 7 5 2 3 41 8 7 5 2 3 41 8 9 6 4There are 8 routes from the firestation to streetcorner 4.
![Page 13: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/13.jpg)
Unit tests
![Page 14: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/14.jpg)
Fail
Pass
![Page 15: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/15.jpg)
![Page 16: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/16.jpg)
![Page 17: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/17.jpg)
Is there more?How do you know when you’re done?
![Page 18: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/18.jpg)
Sample Input
61 21 33 43 54 65 62 32 40 0
4 2 33 45 11 67 88 92 55 73 11 84 66 90 0
Sample Output
CASE 1:1 2 3 4 61 2 3 5 61 2 4 3 5 61 2 4 61 3 2 4 61 3 4 61 3 5 6There are 7 routes from the firestation to streetcorner 6.
CASE 2:1 3 2 5 7 8 9 6 41 3 41 5 2 3 41 5 7 8 9 6 41 6 41 6 9 8 7 5 2 3 41 8 7 5 2 3 41 8 9 6 4There are 8 routes from the firestation to streetcorner 4.
![Page 19: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/19.jpg)
Design Coding Testing
![Page 20: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/20.jpg)
When you actually sit down to write some code, you learn things that you didn’t get from thinking about them in modeling terms…there is a feedback process there that you can only really get at from executing some things and seeing what works
- Martin Fowler
![Page 21: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/21.jpg)
Design Testing Coding
![Page 22: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/22.jpg)
Testing Coding Design
![Page 23: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/23.jpg)
Test Driven Development: By Example
![Page 24: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/24.jpg)
![Page 25: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/25.jpg)
![Page 26: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/26.jpg)
![Page 27: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/27.jpg)
![Page 28: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/28.jpg)
•Write a failing test = Red•Make the test pass = Green•Refactor = Refactor
![Page 29: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/29.jpg)
RedGreen
Refactor
![Page 30: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/30.jpg)
Make the Test Pass?
![Page 31: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/31.jpg)
Uncle Bob’s Three Laws of TDD• You are not allowed to write any production code unless it is to make
a failing unit test pass.• You are not allowed to write any more of a unit test than is sufficient
to fail; and compilation failures are failures.• You are not allowed to write any more production code than is
sufficient to pass the one failing unit test.
![Page 32: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/32.jpg)
Rule of Perpetual
Inconsequence
![Page 33: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/33.jpg)
![Page 34: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/34.jpg)
FizzBuzz• If multiple of 3, get “Fizz”• If multiple of 5, get “Buzz”• If not, return input int as string•Rules are in order
![Page 35: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/35.jpg)
Fizz Buzz!Code!
![Page 36: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/36.jpg)
Clean Code that Works
![Page 37: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/37.jpg)
XP Simple Design•Passes all tests•Clear, expressive, consistent•No duplication•Minimal
![Page 38: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/38.jpg)
![Page 39: Put the Tests Before the Code](https://reader036.fdocuments.net/reader036/viewer/2022062900/58eb34601a28ab6d778b46ff/html5/thumbnails/39.jpg)
Mike Clement• @mdclement• [email protected]• http://blog.softwareontheside.com• https://github.com/mdclement• http://agilecodegames.com
• Greater Sum• @thegreatersum• http://www.greatersum.com
• Software Craftsmanship Atlanta• Find us on meetup.com