Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Real-world TDD on App
Engine
Mistakes Made and Lessons Learned
Adewale Oshineye




Developer Advocate @ Google
Projects and Examples


JaikuEngine: http://code.google.com/p/jaikuengine/
FeedParser: http://code.google.com/p/feedparser...
TDD Is Hard
Especially On App Engine
What makes TDD on App
     Engine hard?
Models are Active Records


Models have a lifecycle (transient to persistent)
Tests need datastore
Keys are usually auto-g...
Platform and services


 System services are opaque
 Development environment isn’t an exact mirror of
 production environm...
What should we do?
What should we do?




http://en.wikipedia.org/wiki/File:John_Major,_October_2007.jpg
What should we do?
                                              “We will do precisely what
                              ...
What did I do?
Exploration


 New to App Engine
 New App Engine services
Exploration


 Mock-up the UI
 Write handlers
 Get it working
Exploration


 Realisation
 Regret
 Refactor
Exploration


 Add tests
 Extract testable classes
 Add more tests
What should you do?
2 books
Exploitation

 Vertical slice for one feature
 Mock-up the UI
 Refine
Exploitation




 Write functional tests at the WSGI level
Exploitation




 Sketch out handlers
Exploitation

 Write unit tests
 Write domain classes
Exploitation
 Passing unit tests
 Passing functional tests
Exploitation



 Red-Green-Refactor
Exploitation


 UI does the right thing
 Repeat for next feature
Ways and means

Find a good testing framework
  nosegae and gae-testbed
  learn how to use stubs for the various platform
...
Heuristics

  Domain objects don’t have to be model objects
  Use simple factories for model objects
Heuristics


   If in doubt, write a test
   Testability requires work
   If it’s hard to test it’s probably broken
Heuristics


   Some things can only be understood in production
   End-to-end is further than you think
     even if you ...
References

gae-testbed http://github.com/jgeewax/gaetestbed/
nose-gae http://code.google.com/p/nose-gae/
nose http://code...
Test Driven Development on Google App Engine
Test Driven Development on Google App Engine
Test Driven Development on Google App Engine
Test Driven Development on Google App Engine
Upcoming SlideShare
Loading in …5
×

Test Driven Development on Google App Engine

8,289 views

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

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/

×