they are testing. Related test methods reside in the same TestCase. Tests should not rely on documentation to explain what they are doing. Developers reading the tests should not have to leave the TestCase code to determine what the test is doing.
and test assertions again. • Don’t extend your test further. • Don’t create test methods that chain together main tests. • Write a new test method, and copy the pre-conditions.
one path through the code under test. The set of TestCases will define a clear contract with the developer. For any test that fails, the cause will be easy to pinpoint because the expected results is clearly focused.
grow over time. Shared helper methods try to be generic enough for everyone to use. Impose a lookup burden on readers of the test code. Tend to become complex over time (do your tests need tests)?
ORM. Give us hooks into data preparation. FactoryBoy lets us define data across relationships using familiar `double- underscore` notation. We can define associations in FactoryBoy to mimic our business logic.
a database transaction which gets rolled-back. History shows you can’t rely on developers to tearDown properly. * Only applies to the `default` database.
extends a BaseTestCase, it will run all tests, even the ones in the BaseTestCase. Leads to the same tests being run many times unnecessarily. Use a mixin - it will not be run by the test runner.
data is cleaned up - especially when using django signals. If we want to use multi-processing for tests, we need to be sure test methods can be run in any order. Over the entire test suite, did not give us enough gains to overcome the potential pitfalls. Using multi-processing for tests gave us much better wins.