Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What your tests are telling you

What your tests are telling you

This is a talk I gave for a ruby meetup in Santiago de Chile, http://www.meetup.com/dynlangchile/events/114324612/ talking a little about the thinks in Test Driven Development appart from Test First.

Special credits to Zach Holman, for http://zachholman.com/posts/slide-design-for-developers/

My first slides are way too similar to Holman's but I gonna create my own style for my talks incrementally

Felipe Espinoza

April 23, 2013
Tweet

More Decks by Felipe Espinoza

Other Decks in Programming

Transcript

  1. what your TESTS by Felipe Espinoza are telling YOU I’m

    using this as a base palette http://www.colourlovers.com/palette/2815221/Space_Travel
  2. Testing is GOOD IN THEORY In reality is “Why we

    usually don’t test our apps?”
  3. Tests Maintainability What if I change my form id to

    #new_awesome_form? PROBLEM PROBLEM: Little changes causes lots of errors
  4. ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project % rspec spec ....F....F..F.....

    PROBLEM PROBLEM: Test are not trustworthy because they fail randomly
  5. ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project % rspec spec ......F..F........

    ~/my_awesome_project % rspec spec ....F....F..F..... PROBLEM PROBLEM: Test are not trustworthy because they fail randomly
  6. ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project % rspec spec ......F..F........

    ~/my_awesome_project % rspec spec ....F....F..F..... Pray-Driven Development PROBLEM PROBLEM: Test are not trustworthy because they fail randomly
  7. Other Testing Smells PROBLEM Class difficult to test Wish to

    access private variable Difficult Test Setup Dependent of external services Difficult Mocking State Leaks across tests PROBLEM: a list of other testing smells
  8. A simple Rails Test Case... ~/Talks/testing/shopping_cart_example ☺ time rspec spec

    .. Finished in 0.07256 seconds 2 examples, 0 failures rspec spec 2.73s user 0.30s system 99% cpu 3.035 total
  9. A simple Rails Test Case... ~/Talks/testing/shopping_cart_example ☺ time rspec spec

    .. Finished in 0.07256 seconds 2 examples, 0 failures rspec spec 2.73s user 0.30s system 99% cpu 3.035 total
  10. A simple Rails Test Case... ~/Talks/testing/shopping_cart_example ☺ time rspec spec

    .. Finished in 0.07256 seconds 2 examples, 0 failures rspec spec 2.73s user 0.30s system 99% cpu 3.035 total
  11. It is rails boot time! We can add Spork, Zeus,

    etc, to speed up the rails boot time Test First
  12. It is rails boot time! Or we can extract our

    logic outside rails! Test Driven Development We can add Spork, Zeus, etc, to speed up the rails boot time Test First VS
  13. Testing outside rails... ~/Talks/testing/shopping_cart_example ☺ time rspec spec/lib .. Finished

    in 0.00137 seconds 2 examples, 0 failures rspec spec/lib 0.56s user 0.08s system 98% cpu 0.643 total
  14. Testing outside rails... ~/Talks/testing/shopping_cart_example ☺ time rspec spec/lib .. Finished

    in 0.00137 seconds 2 examples, 0 failures rspec spec/lib 0.56s user 0.08s system 98% cpu 0.643 total
  15. Extracting Behavior as Macro... We are localizing some behavior in

    files, and creating a custom DSL for testing our application
  16. Extracting Behavior as Macro... We are localizing some behavior in

    files, and creating a custom DSL for testing our application
  17. What about PDD... ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project %

    rspec spec ......F..F........ ~/my_awesome_project % rspec spec ....F....F..F..... 1 1. Pray Driven Development
  18. What about PDD... ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project %

    rspec spec ......F..F........ ~/my_awesome_project % rspec spec ....F....F..F..... Timebox 1 1. Pray Driven Development
  19. What about PDD... ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project %

    rspec spec ......F..F........ ~/my_awesome_project % rspec spec ....F....F..F..... Timebox Rethink 1 1. Pray Driven Development
  20. What about PDD... ~/my_awesome_project % rspec spec ....F............. ~/my_awesome_project %

    rspec spec ......F..F........ ~/my_awesome_project % rspec spec ....F....F..F..... Timebox Rethink Delete 1 1. Pray Driven Development
  21. Robbie Clutton & Matt Parker, It’s not your test framework,

    it’s you goo.gl/MCftE http://vimeo.com/15007792 Michael Feathers, The Deep Synergy between Testability and Good Design @mfeathers