Unit Testing with Django Models and a lot of relations involved

Viewed 5705

Or, "How to design your Database Schema for easy Unit testing?"

By the way, there is a very similar question to this here: How to test Models in Django with Foreign Keys

I'm trying to follow TDD methodology for a project that uses the framework Django. I'm creating and testing models and its functionality (save methods, signals,...) and other high level functions that relies on the models.

I understand that unit testing must be as isolated as possible but I find myself creating a lot of tables and relations using FactoryBoy for each test, so my test is not strong enough because if something changes in a model many tests could be broken.

How to avoid all these dependencies and make the test cleaner?

What do you guys recommend to avoid all that boilerplate before the actual test?

What are the best practices?

3 Answers
Related