$30 off During Our Annual Pro Sale. View Details »

Quid Est Testing?

Quid Est Testing?

What are the basics of testing? How do we test?

Given to the RIT Society of Software Engineers in 2009. http://sse.se.rit.edu/

Nick Quaranto

January 12, 2012
Tweet

More Decks by Nick Quaranto

Other Decks in Programming

Transcript

  1. quid est testing?
    nick quaranto

    View Slide

  2. 5th year SE & CS major
    ruby fanatic
    bills fan
    @qrush
    litanyagainstfear.com

    View Slide

  3. http://quid.heroku.com

    View Slide

  4. what is testing?

    View Slide

  5. View Slide

  6. View Slide

  7. not:
    refreshing
    compiling
    for someone else to do

    View Slide

  8. empirical investigation conducted to provide
    stakeholders with information about the
    quality of the product or service under test
    wikipedia

    View Slide

  9. tl;dr

    View Slide

  10. the process of executing a program or system
    with the intent of finding errors
    the art of software testing

    View Slide

  11. closer...

    View Slide

  12. clean code that works

    View Slide

  13. acceptance testing
    integration testing
    functional testing
    unit testing

    View Slide

  14. acceptance testing
    integration testing
    functional testing
    unit testing

    View Slide

  15. what is a unit?

    View Slide

  16. programmer tests

    View Slide

  17. define what it means for the code to
    work

    View Slide

  18. why should I test?

    View Slide

  19. predictability
    have a process
    know you are finished

    View Slide

  20. tighter feedback loops
    running code informs decisions
    learn lessons faster

    View Slide

  21. dependability
    build trust
    know immediately when you break something

    View Slide

  22. loose coupling
    easy to test
    not just a buzzword

    View Slide

  23. how do you test?

    View Slide

  24. setup
    exercise
    verification
    teardown

    View Slide

  25. same process for any language
    test methods run in isolation
    let's do some ruby

    View Slide

  26. require 'test/unit'
    class BillsPlayerTest < Test::Unit::TestCase
    def test_to_is_a_tad_bit_hyped
    end
    end

    View Slide

  27. setup
    terrell_owens = BillsPlayer.new

    View Slide

  28. exercise
    terrell_owens.overpaid?

    View Slide

  29. verification
    assert

    View Slide

  30. other assertions
    assert_equal "wide receiver",
    terrell_owens.position
    assert_not_nil terrell_owens.number
    assert_raises InterceptionError do
    terrell_owens.miss_route!
    end

    View Slide

  31. class BillsPlayerTest < Test::Unit::TestCase
    def test_to_is_a_tad_bit_hyped
    terrell_owens = BillsPlayer.new
    assert terrell_owens.overpaid?
    end
    end

    View Slide

  32. class BillsPlayerTest < Test::Unit::TestCase
    def setup
    @terrell_owens = BillsPlayer.new
    end
    def test_to_is_a_tad_bit_hyped
    assert @terrell_owens.overpaid?
    end
    def teardown
    # bills lose, again :[
    end
    end

    View Slide

  33. so what?
    production errors due to uncomprehensive tests
    often done after the code is written
    if not automated, not preformed frequently
    and so on...

    View Slide

  34. test driven development

    View Slide

  35. you, the developer, write the tests!
    write tests before implementation
    new code only when an automated test fails
    take small steps

    View Slide

  36. the process
    write a test
    watch it fail
    write just enough code to make it pass

    View Slide

  37. let's do this

    View Slide

  38. feedback loop
    red
    green
    refactor

    View Slide

  39. refactor
    eliminate duplication
    rename
    single responsibility
    and so on...

    View Slide

  40. tdd is about design
    design is a process, not a phase
    think about the interface before
    implementation

    View Slide

  41. when do I test?

    View Slide

  42. TATFT

    View Slide

  43. the drawbacks

    View Slide

  44. all walk, no talk
    easier with a pair
    team buy-in

    View Slide

  45. some thoughts...

    View Slide

  46. it's ok not to test!

    View Slide

  47. testing vs. spiking

    View Slide

  48. dependencies
    fakes
    stubs
    mocks

    View Slide

  49. find a coop (or job) that helps you
    test

    View Slide

  50. ask about policies on testing

    View Slide

  51. TATFT

    View Slide