Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this questionI have read a lot of essays talking about benifits TDD can bring to a project, but I have never practiced TDD in my own project before.
Now I'm starting an experimental project with Django, and I think maybe I can have a try of TDD.
But what I find now is that I don't even know how to answer the question "what should I put in my test cases?".
Please tell me how should I plan TDD in a project, in this case, a we开发者_JS百科b project based on Django.
Thanks.
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!)
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.
精彩评论