Code

Changes between Version 6 and Version 7 of TestingGuide


Ignore:
Timestamp:
02/10/09 06:11:40 (5 years ago)
Author:
nielsw
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TestingGuide

    v6 v7  
    11= Django Testing Guide = 
    2 Testing web applications has historically been hard. It's even harder to write unit tests that work well when someone integrates your app. This guide aims to provide pointers and best practises for  
    3 testing your apps and writing portable unit tests. 
     2Testing web applications has historically been hard. It's even harder to write unit tests that work well when someone integrates your app. This guide aims to provide pointers and best practices for testing your apps and writing portable unit tests. 
     3 
     4Though there are multiple types of automated tests, this article deals with unit tests. Unit testing is often combined with test-driven development. This means you write your test first and then implement code to make the test pass. The basic workflow is: 
     5 
     61. Write the test case[[BR]] 
     72. Run the test case (to make sure it fails)[[BR]] 
     83. Write the implementation code[[BR]] 
     94. Run the test case (to make sure it passes)[[BR]] 
    410 
    511== Writing portable tests == 
     
    915 
    1016If 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. 
     17 
     18=== tests should test one thing === 
     19A good test tests one thing, not five or ten. If you have multiple  
    1120 
    1221=== test_urls ===