Juan Yanez
Juan Yanez

Reputation: 95

How to test a Django app

I´m quite new at python/django development and I would like to know what's the best way to test these kinds of applications. I've been doing a little research and I found libraries like magicmock or minimock but I don't really have any idea if they're good or bad or what are the best practices for Django. Can anyone give me some tips? The project I'm working on it's this one https://github.com/Smart-Studio/fbclm-backend/tree/develop , just in case someone wants to take a look a it.

Thanks!

Upvotes: 0

Views: 287

Answers (1)

codingcoding
codingcoding

Reputation: 751

The Official Django Tutorial touches on testing in chapter 5.

The book Test-Driven Development with Python by Harry Percival (O’Reilly) is available free online. It is a tutorial on building a Django project with complete, comprehensive testing. Be warned, it is very slow paced, sometimes frustrating. The author is dead serious about testing every little thing, and he knows his stuff. There is much to be learned from him.

Edit: Some of the remarks above are not fair. I was about a third of the way through Percival's book when I gave this answer. The author's style of teaching is not slow. The pace is comfortable. The author does lead the reader to type some code only to replace it later, but this does help to understand how the process being tested actually works. For someone who is unfamiliar with TDD, the building process can feel painfully slow. You can write several lines of testing code for every single line of application code, before even writing any of the application code. The author doesn't test "every little thing". He gives the reader guidelines to help decide what does and doesn't need to be tested, and there are several things that need to be tested if you really want good coverage.

I apologize for taking this out of the Stackoverflow context for answers. In this case, the crime had already been committed and this edit was required to fix the bug in my answer.

Upvotes: 2

Related Questions