开发者

What kind of tests should one write in Django

Let's says I have a Djano app. Users can sign up, get a activation mail, activate their accounts and log in. After logging in, users can can create, update and delete objects rhough a custom Form which uses the Manager to handle the Model.

What should I be testing here — should I use the request framework to make requests and test the whole chain via the Views and Forms or should I be writing unit tests to test the Manager and the Model?

When testing the whole chain, I get to see that the URLs are configured properly, the Views work as expecvted, the Form cleans the data properly and it would also test the Models and Managers. It seems that the Django test framework is more geared toward unit-testing than this kind of test. (Is this something that should be tested with T开发者_JAVA技巧will and Selenium?)

When writing unit tests, I would get to test the Manger and the Models but the URLs and the Forms don't really come into play, do they?!

A really basic question but I'd like to get some of the fundamentals correct.

Thank you everyone.


Yes, Django unit tests, using the Client feature, are capable of testing whether or not your routes and forms are correct.

If you want full-blown behavior-driven testing from the outside, you can used a BDD framework like Zombie.

As for which tests you need, Django author Jacob Kaplan-Moss answered the question succinctly: "All of them."

My general testing philosophy is to work until something stupid happens, then write a test to make sure that stupid thing never happens again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜