Unit testing in Django?
https://news.ycombinator.com/item?id=903344I've been attempting to discipline myself into making more extensive use of testing in general, but of late, in Django.
There are parts of the project I'm working on that need refactored and writing tests that have good coverage of the various function points is going to put me in a better position to be able to refactor confidently. For reasons that should be obvious, I've begun implementing unit tests in the "account" app within the project.
I've managed to break the account registration and transaction process into three unit tests so far, but one of the tests seems a bit too big/fat, and it's a little bit repetitious. The reason for this is that the transaction is stateful and I cannot rely on globals for unit tests. (Test order not guaranteed, cannot use that.)
So that would be my first question, how do I cope with a stateful transaction in terms of breaking it down more? Just deal with the fact that I'm repeatedly retrieving and validating the same data cross more than one test, or is there a better way?
More importantly, are there any books/materials/tutorials that take a pragmatic viewpoint on unit testing in development (ie, not rigidly 'test first') that you would recommend?
Test-first methodology isn't really an option aesthetically and practically because I'm coming into an ongoing project and the culture/practice wasn't there for it. I'm the first one to start making use of tests.
Thanks.