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

Unit testing in python

Unit testing in python

motivation, techniques and tools

Gabriel Falcão

February 06, 2012
Tweet

More Decks by Gabriel Falcão

Other Decks in Programming

Transcript

  1. Past •Tests were written after the code was “ready” •Mocks,

    Stubs, are also an old concept: isolate modules •Microsoft, Sun and other huge software companies were using since... ever
  2. Present •Kent Back changed the world •Google, Facebook, [your badass

    company here] doing •Mocks, Stubs, now are less heavily used
  3. Why is it cool ? •Automagic refactoring •Modules are isolated

    •Code is cleaner •Modules are isolated •No more fear when changing code that is too important •They run just so fast •White box
  4. White box •Comes from hacking/security vocabulary •The developer knows the

    codebase in depth •Test relies on internal calls
  5. Baby steps •Don’t write the whole thing at once •The

    next step will come naturally •Small units of code •The name is cute
  6. Python - Past •unittest and unittest2 •class-based •camel case •overcomplicated

    •the community wasn’t really into it •... so we didn’t have many libraries BORING...
  7. Python - Present •Nose — •DSLs are growing and becoming

    more popular •it is becoming fun to write tests •so that we’ll want to write more and more ROBUST CODE
  8. How it is •The default test support uses unittest2 •or

    doctests •don’t separate between unit, functional, etc •which leverages having very slow suites •doesn’t provide support for isolation •kinda focused on black box
  9. Unclebob •per app tests (unit, functional, integration) •isolate the database

    so it fails if your test tries to use it •discover tests automagically