GoRuCo talk: Contexts, mocks, and stubs. Oh my!

Presented by Trotter Cashion

Beyond Test::Unit

  • FlexMock
  • Mocha and Stubba
  • Test/Spec – Brings RSpec to Test::Unit
  • spec-unit—Written by Trotter. Similar to Test/Spec. Has nested contexts.
  • RSpec—Total Test::Unit replacement.
    • Switching to RSpec is not necessary to use these concepts.

Why should you care?

  • Contests
    • Let you organize specs with shared setup
    • Isolate specs that should not be affecting eachother
  • Mocks versus stubs
    • Mocks validate the method calls
    • Stubs don’t care
  • Use mocks when you need to be sure
  • Use stubs when you don’t care—helps avoid brittle tests

What I’m not talking about

  • RSpec
  • Mocha and stubba
  • Test/Spec

That leaves…

  • Spec-unit
  • FlexMock

Risks

  • Active development—APIs still changing
  • You might get too excited

Benefits of mocking

  • More focused testing
  • Better application design
    • Mocking lets you think about the interface without building client classes

Code walkthroughs followed…

0 Responses to “GoRuCo talk: Contexts, mocks, and stubs. Oh my!”