WTF is TDDA journey to writing awesome code, one test at a time
WTF well be covering● What is testing and why you are hurting the  world by not doing it● What is TDD, why do it, and why ...
Who TF is this guy?● Steven Nunez (@_StevenNunez)  ○ Junior Developer at Cyrus Innovation    ■ AWESOME PLACE!        ●   A...
Stuff you need to Fing knowHow to read this:class Order attr_reader :items def initialize  @items = Hash.new(0) end def ad...
What Is TestingThe Act of isolating parts of your code with aknown state to ensure it works as expected.Setup follows AAA ...
Types of testing● End to end tests/ Acceptance tests  ○ Here there be Cucumbers. Capybara, Webrat  ○ Used to ensure system...
Why Test● Lets you know when things broke  ○ Youd be surprised how code works● Allows for courageous refactoring● Gives do...
Testing basicsWell be using Rspec...http://rspec.info/https://github.com/rspec/rspec-expectations#built-in-matchersCodey C...
What is Test DrivenDevelopment?
Why do TDD?● Forces you to think small             ○ You have a clear objective● Less thoughts to juggle             ○ All...
How to TDDRed Green Refactor1. Write a test.2. Watch it fail.3. Write code to pass your test.4. Look for ways to make your...
Our projectOur client is developing a social network based for his Restaurant customers. Hed want to eventually have peopl...
Your task!Pair up and work on getting therecommendation engine up.Noobs, pair up with Wizards.TDD ONLY!https://github.com/...
Questions!
TaskMenu#recommendations(:bacon)# => [:bacon_cheeseburger, :blt, :bacone ]Socializer#socialize!# customer_1.hook_up(custom...
Resourceshttps://www.relishapp.com/rspechttp://pragprog.com/book/achbd/the-rspec-bookPractical Object Oriented Design by S...
THANKS!
Upcoming SlideShare
Loading in …5
×

WTF is TDD

414 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
414
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

WTF is TDD

  1. 1. WTF is TDDA journey to writing awesome code, one test at a time
  2. 2. WTF well be covering● What is testing and why you are hurting the world by not doing it● What is TDD, why do it, and why its better than writing tests AFTER youve written your code● See code that was developed using TDD● Extending this code
  3. 3. Who TF is this guy?● Steven Nunez (@_StevenNunez) ○ Junior Developer at Cyrus Innovation ■ AWESOME PLACE! ● Agile/TDD All day, Eryday ○ Organizer of Unearth Ruby ■ http://www.meetup.com/unearthruby/ ○ Co-Organizer of NYC Rubyist Roundtable ■ http://www.meetup.com/nycruby/
  4. 4. Stuff you need to Fing knowHow to read this:class Order attr_reader :items def initialize @items = Hash.new(0) end def add(item) items[item] += 1 endend
  5. 5. What Is TestingThe Act of isolating parts of your code with aknown state to ensure it works as expected.Setup follows AAA principle:ArrangeActAssert
  6. 6. Types of testing● End to end tests/ Acceptance tests ○ Here there be Cucumbers. Capybara, Webrat ○ Used to ensure system works as a whole● Unit Tests ○ Rspec, Test::Unit, Minitest ○ View tests ○ Controller tests ○ Model tests
  7. 7. Why Test● Lets you know when things broke ○ Youd be surprised how code works● Allows for courageous refactoring● Gives documentation on how your code is SUPPOSED to work● It is your duty to deliver working code.
  8. 8. Testing basicsWell be using Rspec...http://rspec.info/https://github.com/rspec/rspec-expectations#built-in-matchersCodey Code! ----> http://bit.ly/PUwQLf
  9. 9. What is Test DrivenDevelopment?
  10. 10. Why do TDD?● Forces you to think small ○ You have a clear objective● Less thoughts to juggle ○ All you know is how you want it to work● Leads to modular code ○ Each part of your code does one job● Write less code● Increase documentation● It makes you happy! ○ Red, Green, REFACTOR!http://edu.mkrecny.com/thoughts/be-nice-to-programmers
  11. 11. How to TDDRed Green Refactor1. Write a test.2. Watch it fail.3. Write code to pass your test.4. Look for ways to make your code more expressive5. GOTO 1
  12. 12. Our projectOur client is developing a social network based for his Restaurant customers. Hed want to eventually have people withsimilar food interests meet up and discuss how his food changed their lives. ● A few features he wants are: ○ The ability to have users discover new foods based on ingredients they love (Bacon!) ○ The ability to find users with similar food interests. The system will automatically share their phone numbers with each other. (He thinks theyll be ok with this)What do you need first?I need a way to capture customer orders based on their menu.Things we builtA Menu with Menu Items in it.The Items need to have a name, price, calorie count, and ingredientsOrders consist of a menu item, and a quantity.Orders can calculate their total
  13. 13. Your task!Pair up and work on getting therecommendation engine up.Noobs, pair up with Wizards.TDD ONLY!https://github.com/StevenNunez/FinerDiner
  14. 14. Questions!
  15. 15. TaskMenu#recommendations(:bacon)# => [:bacon_cheeseburger, :blt, :bacone ]Socializer#socialize!# customer_1.hook_up(customer_2)
  16. 16. Resourceshttps://www.relishapp.com/rspechttp://pragprog.com/book/achbd/the-rspec-bookPractical Object Oriented Design by SandyMentzhttp://www.poodr.info/
  17. 17. THANKS!

×