Changes between Version 9 and Version 10 of TestingGuide


Ignore:
Timestamp:
02/12/2009 07:00:19 AM (6 years ago)
Author:
nielsw
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TestingGuide

    v9 v10  
    1212Portable tests, like portable software, are tests that will run properly regardless of how the and where the test code is executed. It could be your app will be ran standalone or integrated in a bigger project.
    1313
     14=== Write your views using classes instead of functions ===
     15When you write your view as a class with a __call__ method. This offers a way to split the __call__ method into multiple methods while still showing that the methods belong to a specific view (and are only called by this view). If you choose to write a lot of functions which are not grouped by using a class stuff can get messy real fast.
     16
    1417=== tests should run in isolation ===
    1518Whenever possible use test_urls and dedicated test templates to make sure your tests run as isolated. Usually you will want to write your test in such a way that they will only fail when there a failure in what you're testing. What you don't want is your unit tests failing because someone decided to put a bad template tag in your non-test template.
    1619
    17 If at all possible you should avoid using Django's test client, too. Why? Because it often introduces failures which are not related to your code (e.g. middleware). If you're going to do anything more complex than getting or setting a variable in Django, write a method class to do that and test it directly.
     20If at all possible you should avoid using Django's test client, too. Why? Because it often introduces failures which are not related to your code (e.g. middleware). If you're going to do anything more complex than getting or setting a variable in Django, write a method class to do that and test it directly. When you are using Django's test client you're actually writing integration tests instead of unit tests because you are not testing methods and functions in isolation but you're testing the framework as a whole.
    1821
    1922=== tests should test one thing ===
Back to Top