Test Driven Development on Google App Engine


Published on

This talk is aimed at people who are already familiar with Python and App Engine but want to know how they can apply the techniques of TDD in this environment. The talk is focussed on sharing and improving upon the lessons I learned in the process of building and maintaining various web applications.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

  • Test Driven Development on Google App Engine

    1. 1. Real-world TDD on App Engine Mistakes Made and Lessons Learned
    2. 2. Adewale Oshineye Developer Advocate @ Google
    3. 3. Projects and Examples JaikuEngine: http://code.google.com/p/jaikuengine/ FeedParser: http://code.google.com/p/feedparser/ Streamer: http://github.com/adewale/streamer
    4. 4. TDD Is Hard
    5. 5. Especially On App Engine
    6. 6. What makes TDD on App Engine hard?
    7. 7. Models are Active Records Models have a lifecycle (transient to persistent) Tests need datastore Keys are usually auto-generated
    8. 8. Platform and services System services are opaque Development environment isn’t an exact mirror of production environment
    9. 9. What should we do?
    10. 10. What should we do? http://en.wikipedia.org/wiki/File:John_Major,_October_2007.jpg
    11. 11. What should we do? “We will do precisely what the British nation has done all through its history when it had its back to the wall — turn round and fight for the things it believes in, and that is what I shall do.” http://en.wikipedia.org/wiki/File:John_Major,_October_2007.jpg
    12. 12. What did I do?
    13. 13. Exploration New to App Engine New App Engine services
    14. 14. Exploration Mock-up the UI Write handlers Get it working
    15. 15. Exploration Realisation Regret Refactor
    16. 16. Exploration Add tests Extract testable classes Add more tests
    17. 17. What should you do?
    18. 18. 2 books
    19. 19. Exploitation Vertical slice for one feature Mock-up the UI Refine
    20. 20. Exploitation Write functional tests at the WSGI level
    21. 21. Exploitation Sketch out handlers
    22. 22. Exploitation Write unit tests Write domain classes
    23. 23. Exploitation Passing unit tests Passing functional tests
    24. 24. Exploitation Red-Green-Refactor
    25. 25. Exploitation UI does the right thing Repeat for next feature
    26. 26. Ways and means Find a good testing framework nosegae and gae-testbed learn how to use stubs for the various platform services learn how to cycle between functional and unit tests
    27. 27. Heuristics Domain objects don’t have to be model objects Use simple factories for model objects
    28. 28. Heuristics If in doubt, write a test Testability requires work If it’s hard to test it’s probably broken
    29. 29. Heuristics Some things can only be understood in production End-to-end is further than you think even if you take this into account
    30. 30. References gae-testbed http://github.com/jgeewax/gaetestbed/ nose-gae http://code.google.com/p/nose-gae/ nose http://code.google.com/p/python-nose/ Webtest http://pythonpaste.org/webtest/