The Missing Ingredient


by Salman Ansari

About Me



  • I am a walking ad for United Colors of Benetton
  • I did the startup thing (involver) in San Francisco
  • I moved to NYC after Oracle acquisition
  • I taught Ruby & Rails at General Assembly in NYC
  • I'm Head Lecturer at iExperience
  • I'm an audiophile who DJs for fun
  • Lastly, before you ask...

I'M NOT RELATED

TO AZIZ ANSARI


Agenda


  • Why Test?
  • The Choppy Waters
  • Seeking Help
  • The Missing Ingredient
  • The TDD Flow
  • Summary

    Why Test?


    • We often find peers/guidance that encourages us to test
    • Resources on how to test are readily available
    • The general assumption is that testing is good
    • Most people don't know why they should test
    • Resources on why to test are scarce
    • Before we adopt a solution, we must comprehend
      what problems it is solving
    • I learned the why the hard way...

    Choppy Waters

    Problems


    Too many bugs

    Goals


    Less bugs

      Initial Approach


        1. When a new feature is complete, write tests to cover it.
        2. If we hit a bug on production, write a test for that case.
        3. Otherwise, continue development as usual.

      Results


      • No real change in bug frequency
      • Increase in developer frustration
      • Low team confidence in testing 

        Getting Perspective


        • Began working with a team experienced in Agile, TDD, and pair programming.
        • We were looking for them to help us reduce the bugs, but they helped us identify a number of other issues...

        Real Problems


        • Untracked work => unecessary code
        • Fear of breaking changes => lack of refactors
        • Inadequate docs => uninformed technical decisions
        • Ambiguous feature specs => features 'lost in translation'
        • Ineffective tests => lots of bugs

        Lessons Learned


        • It's incredibly helpful to get help
        • Our problems were far deeper than we thought
        • Testing alone could not solve all our problems
        • We needed to change our entire development flow

        The Missing Ingredient:

        Process

        New Approach


        • Work outside-in: start from the business view
        • Ensure specifications are clear & complete
        • Only write tests to satisfy a story requirement
        • Only write code to make a test pass
        • Leave the codebase cleaner than you found it

        Results


        • Less bugs
        • Less QA rejections
        • Less features 'lost in translation'
        • Greater iteration speed
        • Greater customer satisfaction
        • More documentation
        • More stress-free refactors
        • More happiness :)

        Why Test?


        It makes you happy.

        The TDD Flow

        TDD Flow


        User Can Add New TV Shows


        As a user,
        When I am on the TV show list page,
        And I click on the "New" button,
        Then I should be redirected to a "New Show" page

        When I fill in the text box for "Title" with a valid title,
        And I fill in the text box for "Description" with a valid description,
        And I click "Submit",
        Then I should see a success message "Your TV show was created successfully"
        And I should be taken to the TV show list page,
        And I should see the new show in the list

        Acceptance Test

        spec/requests/shows_spec.rb


        Rinse & Repeat


        • Go for Green
        • Test by Hand
        • Clean Up & Refactor
        • Deliver with a Smile

        Summary


        • Make sure you know why before you jump
        • Model your entire process around testing
        • Let the business needs drive your work
        • Testing is a universal concept
        • Don't be discouraged; iterate regularly
        • Optimize for happiness

        Resources



        Thanks!

        Questions?



        contact:
        @daretorant

        slides:
        http://slides.com/salmanansari/testing
        Made with Slides.com