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

Do we need any more test frameworks?

lazyatom
February 07, 2011

Do we need any more test frameworks?

A talk I gave at LRUG in 2011, about the plethora of testing frameworks in Ruby, and the urge to write my own

lazyatom

February 07, 2011
Tweet

More Decks by lazyatom

Other Decks in Programming

Transcript

  1. you
    an
    existing
    library
    (the horse is
    probably your ego)

    View Slide

  2. you your
    ideal
    library

    View Slide

  3. language ✘
    app framework ✘
    test framework ✔

    View Slide

  4. test/unit
    rspec
    cucumber

    View Slide

  5. before / setup
    test ...
    should ...
    it ...
    after / teardown

    View Slide

  6. blah = Hubris.new do
    before do
    @x = 1
    end
    it “works” do
    raise unless 1 == @x
    end
    after do
    @x = nil
    end
    end
    blah.run

    View Slide

  7. class Hubris
    def initialize(&block)
    instance_eval(&block)
    end
    def before(&block)
    @before = block
    end
    def it(name, &block)
    @test = block
    end
    # etc ...
    def run
    instance_eval(&@before)
    instance_eval(&@test)
    instance_eval(&@after)
    end
    end
    stash
    evaluate
    evaluate

    View Slide

  8. before / setup
    test ...
    should ...
    it ...
    after / teardown
    @f = File.new
    @f.unlink
    @f.read

    View Slide

  9. subcontexts:
    parent & child
    def run_befores
    @parent.run_befores if @parent
    instance_eval(&@before)
    end
    def run
    run_befores
    instance_eval(&@test)
    # etc ...
    end

    View Slide

  10. Hubris.new do
    def some_method
    @x = 1
    end
    it “works” do
    raise unless 1 == some_method
    end
    end
    where does this
    method live?

    View Slide

  11. all of this has
    happened before;
    and it will all
    happen again.

    View Slide

  12. View Slide

  13. AXIS OF
    WTF

    View Slide

  14. it’s probably OK.

    View Slide

  15. except maybe it’s
    not OK?

    View Slide

  16. maybe don’t write
    anything.

    View Slide

  17. maybe become a
    contributer.

    View Slide

  18. open source
    responsibility.

    View Slide

  19. give some context.

    View Slide

  20. kill-ish your darlings.
    bit.ly/rubytesting

    View Slide