[update April 2012] : The book is now coming out on O'Reilly! more info here:
Thanks so much for following on this far! I'm afraid that's all there is for now, but I am about to start on the next stage -- a proper book on TDD for web apps.
If you've found the tutorial useful so far, I wonder whether I can solicit some feeback regarding a book version?
Here's the chapter outline I've got so far. Now, remember, this is a very rough draft, and it's very much bound to change, but I'd love to hear your thoughts... Especially about some quite general questions, like:
- Am I broadly covering the right sort of stuff?
- Am I right to spend plenty of time talking about JavaScript, as well as Python?
- What should I choose as my example app? I've written the outline as if it were a forums app, but I'm starting to see the appeal of one of the other classic examples, the "to-do list" (very simple at base, can be extended easily, opportunities for sharing/social bits, plenty of stuff to do on the client-side too...). What would you choose as an example?
The idea is to dive straight in with a practical example, rather than talking a lot of theory up-front. I had originally thought to start with a toy example (cf these 3 abandoned chapters: http://www.tdd-django-tutorial.com/tutorial/6/ ), but I decided that people prefer real practical stuff to toy examples...
I also want the first few chapters to be very short + bit-sized, so that the reader feels like they're really making progress quickly... (the inspiration comes from Kent Beck's TDD by Example, an awesome book)
Essentially part 1 is a re-hash of this online tutorial, using a differnt example app...
- Briefly discuss difference between functional testing (AKA acceptance testing, integration testing, whatever) and unit testing
- Write first test - Introduce Selenium, setUp, tearDown
- Demonstrate we can get it to open a web browser, and navigate to a web page eg - google.com
- Change our test to look for the test server
- Switch to Django LiveServerTestCase. Explain
- Get the first test running and failing for a sensible reason
- Create django project django-admin.py startproject
- It worked!
- Look for "Welcome to the Forums", or similar
- urls.py, direct_to_template ?
- Extend FT to try and log in
- Explain the admin site
- Database setup, settings.py, syncdb, admin.py
- runserver to show login code
- Explain difference between test database and real database
- Fixtures
- Distinction between unit tests and functional tests
- Extend FT to try and create a new topic
- new app
- models.py
- test/code cycle
- urls.py again
- Test view as a function
- assert on string contents
- Introduce template syntax
- Keep testing as a function
- The, introduce the Django Test Client
- time for a bit of theory/philosophy
- "Don't test constants"
- Test logic
- Tests for simple stuff should be simple, so not much effort
- Manually coded HTML
- Refactor test classes
- Sign up, login/logout
- Email?
- Use Django Forms classes
- Martin Fowler
- Tests critical
- Methodical process - explain step by step
- Extend various old unit tests and FTs
- Django Notifications, for post edits
- Using an external library
- "Don't store passwords"
- Discuss challenges of external dependencies
- Simple input validation
- Choose JS unit testing framework (probably Qunit, or YUI)
- Dynamic previews of post input
- Bring in nicer UI elements
- pictures for users
- Introduce one of the client-side js frameworks -- backbone.js / ember.js / angular
- show how Django makes this easy
- we want dynamic notifications of when new posts appear on a thread we're looking at
- Need to spin up, Tornado/Twisted/Gevent as well as Django LiveServerTestCase
- FT opens multiple browser tabs in parallel
- Big change!
- obligatory discussion of NoSQL and MongoDB
- descrine installation, particularities of testing
- Need to build 3 server types
- Jenkins (or maybe buildbot)
- Need to adapt Fts, maybe rely less on LiveServerTestCase
- unit testing memcached
- Functionally testing performance
- Apache ab testing
Well, that's what I have so far. What do you think? Have I missed anything out? Does anything seem superfluous? Most importantly, would you buy it?