24
Your first step should be to read over the django test documentation…
http://docs.djangoproject.com/en/dev/topics/testing/#topics-testing
After that your first test should be as simple as
- Create a test client
- Issue a request for your intended main page
- check the return status code is 200
now run your test, and watch it fail because you don’t have a main page yet.
Now, work on getting that test to pass and repeat the process.
37
I’ve started writing a tutorial on the topic. It covers pretty much all the steps in the official Django tutorial, and it includes full browser-automation testing with Selenium, so you can test javascript too…
http://tdd-django-tutorial.com/
(sources at https://github.com/hjwp/Test-Driven-Django-Tutorial)
[edit 2013-04-15] I’m now writing a book for O’Reilly on the topic. IMO it presents things in a much better way that my old tutorial. Check it out at
http://www.obeythetestinggoat.com/
(it’s still free if you want it to be!)
- [Django]-Expire a view-cache in Django?
- [Django]-Ordering admin.ModelAdmin objects in Django Admin
- [Django]-How to handle request.GET with multiple variables for the same parameter in Django