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

Testing @socialstudios.tv

Ran Tavory
December 27, 2012

Testing @socialstudios.tv

An introduction talk to testing.
Really high level. Some best practices etc.
Python and JavaScript

Ran Tavory

December 27, 2012
Tweet

More Decks by Ran Tavory

Other Decks in Programming

Transcript

  1. Types of tests unit tests functional tests integration tests behavioral

    tests UI testing monkey testing stress testing smoke testing usability testing production testing ... Thursday, December 27, 12
  2. The nice thing Testable == Readable == Reusable == Documented

    == Modular == Robust == Maintainable Thursday, December 27, 12
  3. Observation: Tests == Documentation Good tests document the code they

    are testing If the test passes ⇒ Documentation is up to date They also server as examples Thursday, December 27, 12
  4. TDD 1. Write test first 2. Test fails 3. Write

    code 4. Test passes 5. Commit Red - Green testing Thursday, December 27, 12
  5. Good tests are Repeatable Fast Short Test only one thing

    High coverage Thursday, December 27, 12
  6. Bad test are Slow Depend on externals (fb, other websites,

    db) Require a lot of setup Sometimes pass, sometimes fail Produce a lot of output Have exceptions in the log Thursday, December 27, 12
  7. Side Effects are hard to test Good: def f(x): return

    x * 2 Bad: def g(x): self.y = x * 2 Thursday, December 27, 12
  8. Hard to test global variables current time / timing dependent

    impl untested assumption (such as file load ordering) External state (database) Thursday, December 27, 12
  9. External dependencies How do you test facebook? How do you

    test a DAO (data access object) Thursday, December 27, 12
  10. UI Testing It’s hard ⇒ only if you must! Use

    selenium? We have to think about this... Thursday, December 27, 12
  11. Every Commit must be tested New code: TDD or not

    it’s your choice. But you have to submit tested code Legacy code: First wrap with tests Then modify Thursday, December 27, 12