SlideShare a Scribd company logo
1 of 89
Download to read offline
Django Testing
                              Eric Holscher
                         http://ericholscher.com




Tuesday, May 5, 2009                               1
How do you know?

                • First 4 months of my job was porting and testing
                       Ellington

                • Going from Django r1290 to Django 1.0.
                • Suite from 0 to 400 tests.




Tuesday, May 5, 2009                                                 2
30,000 Ft View

                • State of testing in Django
                • Why you should be testing
                • How you start testing
                • Useful tools
                • Eventual Goals



Tuesday, May 5, 2009                           3
State of Django Testing



Tuesday, May 5, 2009                             4
assertTrue('Hello World', community.testing.status)


Tuesday, May 5, 2009                                                         5
Django 1.1

                       Making Testing Possible since 2009




Tuesday, May 5, 2009                                        6
manage.py startapp
                        creates a tests.py



Tuesday, May 5, 2009                         7
from django.test import TestCase

   class SimpleTest(TestCase):
       def test_basic_addition(self):
           quot;quot;quot;
           Tests that 1 + 1 always equals 2.
           quot;quot;quot;
           self.failUnlessEqual(1 + 1, 2)

   __test__ = {quot;doctestquot;: quot;quot;quot;
   Another way to test that 1 + 1 is equal to 2.

   >>> 1 + 1 == 2
   True
   quot;quot;quot;}




Tuesday, May 5, 2009                               8
Fast Tests
                       (Transactions)



Tuesday, May 5, 2009                    9
Minutes (Lower is better)

                                          Ellington Test Speedup
                       60




                       45




                       30




                       15




                        0
                            Django 1.0                               Django 1.1



Tuesday, May 5, 2009                                                              10
You now have no excuse.



Tuesday, May 5, 2009                       11
Why to test



Tuesday, May 5, 2009                 12
Scary
Tuesday, May 5, 2009           13
Less Scary
Tuesday, May 5, 2009                14
Not Scary
Tuesday, May 5, 2009               15
Peace of Mind
Tuesday, May 5, 2009                   16
Code must adapt



Tuesday, May 5, 2009                     17
“It is not the strongest of
                       the species that survives, nor
                        the most intelligent, but the
                          one most responsive to
                                   change.”
                             - Charles Darwin


Tuesday, May 5, 2009                                    18
Won’t somebody please
                        think of the users?!



Tuesday, May 5, 2009                           19
Tests as Documentation




Tuesday, May 5, 2009                            20
Tests as Documentation

                             Test driven development
                                       +
                         Document driven development
                                       =
                          Test Driven Documentation



Tuesday, May 5, 2009                                   20
“Code without tests is
                        broken as designed”
                        - Jacob Kaplan-Moss


Tuesday, May 5, 2009                            21
Dizzying Array of Testing
                               Options



Tuesday, May 5, 2009                               22
What kind of test?


                • doctest
                • unittest




Tuesday, May 5, 2009                         23
Doctests

                • Inline documentation
                • <Copy from terminal to test file>
                • Can’t use PDB
                • Hide real failures
                • “Easy”



Tuesday, May 5, 2009                                 24
def parse_ttag(token, required_tags):
       quot;quot;quot;
       A function to parse a template tag.

         It sets the name of the tag to 'tag_name' in the hash returned.

         >>> from test_utils.templatetags.utils import parse_ttag
         >>> parse_ttag('super_cool_tag for my_object as obj', ['as'])
         {'tag_name': u'super_cool_tag', u'as': u'obj'}
         >>> parse_ttag('super_cool_tag for my_object as obj', ['as', 'for'])
         {'tag_name': u'super_cool_tag', u'as': u'obj', u'for': u'my_object'}

         quot;quot;quot;
         bits = token.split(' ')
         tags = {'tag_name': bits.pop(0)}
         for index, bit in enumerate(bits):
             bit = bit.strip()
             if bit in required_tags:
                 if len(bits) != index-1:
                     tags[bit] = bits[index+1]
         return tags




Tuesday, May 5, 2009                                                            25
Unit Tests

                • Use for everything else
                • More rubust
                • setUp and tearDown
                • Standard (XUnit)




Tuesday, May 5, 2009                          26
import random
   import unittest

   class TestRandom(unittest.TestCase):

         def setUp(self):
             self.seq = range(10)

         def testshuffle(self):
             # make sure the shuffled sequence does not lose any elements
             random.shuffle(self.seq)
             self.seq.sort()
             self.assertEqual(self.seq, range(10))

   if __name__ == '__main__':
       unittest.main()




Tuesday, May 5, 2009                                                        27
Django TestCase

                • Subclasses unittest
                • Fixtures
                • Assertions
                • Mail
                • URLs



Tuesday, May 5, 2009                        28
Test Client


                • Test HTTP Requests without server
                • Test Views, Templates, and Context




Tuesday, May 5, 2009                                   29
from django.contrib.auth.models import User
   from django.test import TestCase
   from django.core import mail

   class PasswordResetTest(TestCase):
       fixtures = ['authtestdata.json']
       urls = 'django.contrib.auth.urls'

       def test_email_not_found(self):
           quot;Error is raised if the provided email address isn't currently registeredquot;
           response = self.client.get('/password_reset/')
           self.assertEquals(response.status_code, 200)
           response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})
           self.assertContains(response, quot;That e-mail address doesn&#39;t have an associated user
   accountquot;)
           self.assertEquals(len(mail.outbox), 0)




Tuesday, May 5, 2009                                                                                  30
What flavor of test?


                • Unit
                • Functional
                • Browser




Tuesday, May 5, 2009                         31
Unit test


                • Low level tests
                • Small, focused, exercising one bit of functionality




Tuesday, May 5, 2009                                                    32
Regression test


                • Written when you find a bug
                • Proves bug was fixed
                • Django Tickets




Tuesday, May 5, 2009                           33
Functional


                • “Black Box Testing”
                • Check High Level Functionality




Tuesday, May 5, 2009                               34
Functional Testing Tools


                • Twill
                • Django Test Client
                • ...




Tuesday, May 5, 2009                              35
Ellington


                • Lots of different clients
                • Need to test deployment (Functional)




Tuesday, May 5, 2009                                     36
go {{ site.url }}/marketplace/search/
   formvalue 1 q pizza
   submit
   code 200




Tuesday, May 5, 2009                       37
Tuesday, May 5, 2009   38
Pretty Functional Tests
Tuesday, May 5, 2009                             39
Can test

                • All sites on a server
                • All sites of a certain type
                • A single problemed client
                • A test across all sites




Tuesday, May 5, 2009                            40
Browser tests

                • Run tests in a web browser
                • Check compatibility of design
                • Basically an IE sanity check
                • Only real way to test JS, AJAX, CSS




Tuesday, May 5, 2009                                    41
Browser Testing Tools


                • Windmill
                • Selenium




Tuesday, May 5, 2009                           42
Tuesday, May 5, 2009   43
Other kinds of testing

                • Spiders
                • Fuzz testing
                • Load testing
                • Prayer




Tuesday, May 5, 2009                            44
Where do I start?



Tuesday, May 5, 2009                       45
Fixed a bug



Tuesday, May 5, 2009                 46
Poking at code on the
                          command line



Tuesday, May 5, 2009                           47
Pony turned Horse



Tuesday, May 5, 2009                       48
Now what?




Tuesday, May 5, 2009               49
Start with a regression
                       test or a functional test



Tuesday, May 5, 2009                               50
Use unittest unless you
                       have a reason not to!



Tuesday, May 5, 2009                             51
Use the data, Luke


                • Use data as a pivot
                • Fixtures means you use Unit Tests
                • Creation on the command line, Doctests




Tuesday, May 5, 2009                                       52
Creating Fixtures

                • ./manage.py dumpdata <app>
                • ./manage.py makefixture Model[x:y]
                       • Follows relations
                • By Hand




Tuesday, May 5, 2009                                  53
TestShell



                       ./manage.py testshell <fixture>




Tuesday, May 5, 2009                                    54
Making Functional tests

                • Usually a relatively annoying process
                • Testmaker makes it easy.
                • ./manage.py testmaker <app>
                • Simply browse and your session is recorded.




Tuesday, May 5, 2009                                            55
Testing your views
                       generally gets you the
                          most coverage.


Tuesday, May 5, 2009                            56
80% Case



Tuesday, May 5, 2009              57
When > Where



Tuesday, May 5, 2009                  58
Tools



Tuesday, May 5, 2009           59
Coverage



Tuesday, May 5, 2009              60
Tuesday, May 5, 2009   61
Mock Objects



                • http://www.voidspace.org.uk/python/mock/




Tuesday, May 5, 2009                                         62
import unittest
   from mock import Mock

   from templatetags.cms_tags import if_link_is_active, IsActiveNode

   class TestIsActiveTag(unittest.TestCase):
       def test_returns_correct_node_type(self):
           token = Mock(methods=['split_contents'])
           token.split_contents.return_value = ('if_link_is_active',
   'bar')

           self.assertEqual(type(if_link_is_active(Mock(), token)),
   IsActiveNode)




Tuesday, May 5, 2009                                                   63
Custom Test Runners



Tuesday, May 5, 2009                         64
Django Test Extensions

                • Gareth Rushgrove
                • Extra Assertions
                • Coverage and XML Test Runners
                • http://github.com/garethr/django-test-extensions




Tuesday, May 5, 2009                                                 65
Django Sane Testing

                • Ella Folk, Lucas (Hi!)
                • Based on nosetests
                • Selenium
                • Live server
                • http://devel.almad.net/trac/django-sane-testing/



Tuesday, May 5, 2009                                                 66
Django Test Utils

                • Mine!
                • Testmaker
                • Crawler
                • Random fanciness
                • http://github.com/ericholscher/django-test-utils/tree/
                       master




Tuesday, May 5, 2009                                                       67
Recording tests is
                       generally seen as bad.



Tuesday, May 5, 2009                            68
My philosophy

                • Write tests.
                • Notice patterns and best practices
                • Automate recording of tests with those patterns
                • If you can’t automate, use tools to make it easier.




Tuesday, May 5, 2009                                                    69
Process for testmaker

                • Most view tests check status_code and response
                       context

                • Write middleware that catches this info
                • Records it to a file
                • Err on the side of more data.



Tuesday, May 5, 2009                                               70
Goals
                       (That perfect world)



Tuesday, May 5, 2009                          71
Some form of TDD


                • Write tests as you write code
                • Makes your code easy to test




Tuesday, May 5, 2009                              72
Follow Django’s Model


                • Tests with every commit
                • Docs with every commit
                • Run tests before commiting




Tuesday, May 5, 2009                           73
Use a DVCS

                • At work we have a central SVN repo
                • Git feature branches
                • Code is staged for documentation and testing
                • Committed to SVN once it is “done”




Tuesday, May 5, 2009                                             74
Continuous Integration



Tuesday, May 5, 2009                            75
NEVER LEAVE THE
                        BUILD BROKEN



Tuesday, May 5, 2009                     76
Love Green
Tuesday, May 5, 2009                77
Fast(er) Tests



Tuesday, May 5, 2009                    78
JSON



Tuesday, May 5, 2009          79
Profiling



                       python -m cProfile manage.py test




Tuesday, May 5, 2009                                      80
Mock Objects



                       http://www.voidspace.org.uk/python/mock/




Tuesday, May 5, 2009                                              81
Future and Ponies



Tuesday, May 5, 2009                       82
Summer of Code


                • Test-Only Models
                • Coverage
                • Windmill tests of the admin




Tuesday, May 5, 2009                            83
Test Suites in Django



Tuesday, May 5, 2009                           84
Central Testing
                        Repository



Tuesday, May 5, 2009                     85
Nose Plugin Integration



Tuesday, May 5, 2009                             86
Things to remember

                • Testing is not hard, you just have to get started.
                • If your code doesn’t have tests, it will be hard/
                       impossible to refactor

                • Once you have tests, you need to run them!




Tuesday, May 5, 2009                                                   87
Credits

       • http://www.flickr.com/photos/tym/192416981/
       • http://www.flickr.com/photos/seandreilinger/2459266781/
       • http://www.homebabysafety.com/images/baby_crawl_suit.jpg
       • http://www.flickr.com/photos/pinkypigs/960572985/




Tuesday, May 5, 2009                                                88

More Related Content

What's hot

Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regexJalpesh Vasa
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slidesSmithss25
 
Write your Helm charts as a professional. Design templates and inheritance. B...
Write your Helm charts as a professional. Design templates and inheritance. B...Write your Helm charts as a professional. Design templates and inheritance. B...
Write your Helm charts as a professional. Design templates and inheritance. B...Volodymyr Shynkar
 
Cloud Application Development – The Future is now
Cloud Application Development – The Future is nowCloud Application Development – The Future is now
Cloud Application Development – The Future is nowSPEC INDIA
 
Benefits of using .net maui
Benefits of using .net mauiBenefits of using .net maui
Benefits of using .net mauiNarola Infotech
 
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...GreeceJS
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Introduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS patternIntroduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS patternKnoldus Inc.
 
Database management system chapter15
Database management system chapter15Database management system chapter15
Database management system chapter15Md. Mahedi Mahfuj
 
How to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor NettyHow to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor NettyVMware Tanzu
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)Will Huang
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)Brian Swartzfager
 

What's hot (20)

Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
MERN PPT
MERN PPTMERN PPT
MERN PPT
 
Angular
AngularAngular
Angular
 
Write your Helm charts as a professional. Design templates and inheritance. B...
Write your Helm charts as a professional. Design templates and inheritance. B...Write your Helm charts as a professional. Design templates and inheritance. B...
Write your Helm charts as a professional. Design templates and inheritance. B...
 
Cloud Application Development – The Future is now
Cloud Application Development – The Future is nowCloud Application Development – The Future is now
Cloud Application Development – The Future is now
 
Benefits of using .net maui
Benefits of using .net mauiBenefits of using .net maui
Benefits of using .net maui
 
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...
Introduction to react-query. A Redux alternative? (Nikos Kleidis, Front End D...
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Introduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS patternIntroduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS pattern
 
Database management system chapter15
Database management system chapter15Database management system chapter15
Database management system chapter15
 
Apache Cordova
Apache CordovaApache Cordova
Apache Cordova
 
How to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor NettyHow to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor Netty
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)快速上手 Windows Containers 容器技術 (Docker Taipei)
快速上手 Windows Containers 容器技術 (Docker Taipei)
 
Initiation à Bootstrap
Initiation à BootstrapInitiation à Bootstrap
Initiation à Bootstrap
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)
 

Similar to Django Testing

Keeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesKeeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesXamarin
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slidesericholscher
 
Java E O Mercado De Trabalho
Java E O Mercado De TrabalhoJava E O Mercado De Trabalho
Java E O Mercado De TrabalhoEduardo Bregaida
 
Atlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software CompanyAtlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software CompanyMike Cannon-Brookes
 
JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklChristoph Pickl
 
JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklChristoph Pickl
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Javaguy_davis
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easierChristian Hujer
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And TechniquesJordan Baker
 
Performance tests with Gatling (extended)
Performance tests with Gatling (extended)Performance tests with Gatling (extended)
Performance tests with Gatling (extended)Andrzej Ludwikowski
 
The Art of Unit Testing Feedback
The Art of Unit Testing FeedbackThe Art of Unit Testing Feedback
The Art of Unit Testing FeedbackDeon Huang
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetdevlabsalliance
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
Background Processing in Ruby on Rails
Background Processing in Ruby on RailsBackground Processing in Ruby on Rails
Background Processing in Ruby on Railsrobmack
 

Similar to Django Testing (20)

Unit Test Your Database! (PgCon 2009)
Unit Test Your Database! (PgCon 2009)Unit Test Your Database! (PgCon 2009)
Unit Test Your Database! (PgCon 2009)
 
Keeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg ShacklesKeeping your users happy with testable apps - Greg Shackles
Keeping your users happy with testable apps - Greg Shackles
 
Os Django
Os DjangoOs Django
Os Django
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
 
Becoming Indie
Becoming IndieBecoming Indie
Becoming Indie
 
Java E O Mercado De Trabalho
Java E O Mercado De TrabalhoJava E O Mercado De Trabalho
Java E O Mercado De Trabalho
 
Becoming Indie
Becoming IndieBecoming Indie
Becoming Indie
 
Atlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software CompanyAtlassian - A Different Kind Of Software Company
Atlassian - A Different Kind Of Software Company
 
JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph Pickl
 
JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph Pickl
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Performance tests with Gatling (extended)
Performance tests with Gatling (extended)Performance tests with Gatling (extended)
Performance tests with Gatling (extended)
 
The Art of Unit Testing Feedback
The Art of Unit Testing FeedbackThe Art of Unit Testing Feedback
The Art of Unit Testing Feedback
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdet
 
Writing tests
Writing testsWriting tests
Writing tests
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
Background Processing in Ruby on Rails
Background Processing in Ruby on RailsBackground Processing in Ruby on Rails
Background Processing in Ruby on Rails
 

More from ericholscher

Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edgeericholscher
 
The story and tech of Read the Docs
The story and tech of Read the DocsThe story and tech of Read the Docs
The story and tech of Read the Docsericholscher
 
Read the Docs: A completely open source Django project
Read the Docs: A completely open source Django projectRead the Docs: A completely open source Django project
Read the Docs: A completely open source Django projectericholscher
 
Large problems, Mostly Solved
Large problems, Mostly SolvedLarge problems, Mostly Solved
Large problems, Mostly Solvedericholscher
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suiteericholscher
 

More from ericholscher (6)

Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edge
 
The story and tech of Read the Docs
The story and tech of Read the DocsThe story and tech of Read the Docs
The story and tech of Read the Docs
 
Read the Docs: A completely open source Django project
Read the Docs: A completely open source Django projectRead the Docs: A completely open source Django project
Read the Docs: A completely open source Django project
 
Read the Docs
Read the DocsRead the Docs
Read the Docs
 
Large problems, Mostly Solved
Large problems, Mostly SolvedLarge problems, Mostly Solved
Large problems, Mostly Solved
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 

Recently uploaded

Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Sheetaleventcompany
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escortdlhescort
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceDamini Dixit
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperityhemanthkumar470700
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Sheetaleventcompany
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...lizamodels9
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...lizamodels9
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceDamini Dixit
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwaitdaisycvs
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...lizamodels9
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756dollysharma2066
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsP&CO
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptxnandhinijagan9867
 

Recently uploaded (20)

Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 

Django Testing

  • 1. Django Testing Eric Holscher http://ericholscher.com Tuesday, May 5, 2009 1
  • 2. How do you know? • First 4 months of my job was porting and testing Ellington • Going from Django r1290 to Django 1.0. • Suite from 0 to 400 tests. Tuesday, May 5, 2009 2
  • 3. 30,000 Ft View • State of testing in Django • Why you should be testing • How you start testing • Useful tools • Eventual Goals Tuesday, May 5, 2009 3
  • 4. State of Django Testing Tuesday, May 5, 2009 4
  • 6. Django 1.1 Making Testing Possible since 2009 Tuesday, May 5, 2009 6
  • 7. manage.py startapp creates a tests.py Tuesday, May 5, 2009 7
  • 8. from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): quot;quot;quot; Tests that 1 + 1 always equals 2. quot;quot;quot; self.failUnlessEqual(1 + 1, 2) __test__ = {quot;doctestquot;: quot;quot;quot; Another way to test that 1 + 1 is equal to 2. >>> 1 + 1 == 2 True quot;quot;quot;} Tuesday, May 5, 2009 8
  • 9. Fast Tests (Transactions) Tuesday, May 5, 2009 9
  • 10. Minutes (Lower is better) Ellington Test Speedup 60 45 30 15 0 Django 1.0 Django 1.1 Tuesday, May 5, 2009 10
  • 11. You now have no excuse. Tuesday, May 5, 2009 11
  • 12. Why to test Tuesday, May 5, 2009 12
  • 16. Peace of Mind Tuesday, May 5, 2009 16
  • 17. Code must adapt Tuesday, May 5, 2009 17
  • 18. “It is not the strongest of the species that survives, nor the most intelligent, but the one most responsive to change.” - Charles Darwin Tuesday, May 5, 2009 18
  • 19. Won’t somebody please think of the users?! Tuesday, May 5, 2009 19
  • 21. Tests as Documentation Test driven development + Document driven development = Test Driven Documentation Tuesday, May 5, 2009 20
  • 22. “Code without tests is broken as designed” - Jacob Kaplan-Moss Tuesday, May 5, 2009 21
  • 23. Dizzying Array of Testing Options Tuesday, May 5, 2009 22
  • 24. What kind of test? • doctest • unittest Tuesday, May 5, 2009 23
  • 25. Doctests • Inline documentation • <Copy from terminal to test file> • Can’t use PDB • Hide real failures • “Easy” Tuesday, May 5, 2009 24
  • 26. def parse_ttag(token, required_tags): quot;quot;quot; A function to parse a template tag. It sets the name of the tag to 'tag_name' in the hash returned. >>> from test_utils.templatetags.utils import parse_ttag >>> parse_ttag('super_cool_tag for my_object as obj', ['as']) {'tag_name': u'super_cool_tag', u'as': u'obj'} >>> parse_ttag('super_cool_tag for my_object as obj', ['as', 'for']) {'tag_name': u'super_cool_tag', u'as': u'obj', u'for': u'my_object'} quot;quot;quot; bits = token.split(' ') tags = {'tag_name': bits.pop(0)} for index, bit in enumerate(bits): bit = bit.strip() if bit in required_tags: if len(bits) != index-1: tags[bit] = bits[index+1] return tags Tuesday, May 5, 2009 25
  • 27. Unit Tests • Use for everything else • More rubust • setUp and tearDown • Standard (XUnit) Tuesday, May 5, 2009 26
  • 28. import random import unittest class TestRandom(unittest.TestCase): def setUp(self): self.seq = range(10) def testshuffle(self): # make sure the shuffled sequence does not lose any elements random.shuffle(self.seq) self.seq.sort() self.assertEqual(self.seq, range(10)) if __name__ == '__main__': unittest.main() Tuesday, May 5, 2009 27
  • 29. Django TestCase • Subclasses unittest • Fixtures • Assertions • Mail • URLs Tuesday, May 5, 2009 28
  • 30. Test Client • Test HTTP Requests without server • Test Views, Templates, and Context Tuesday, May 5, 2009 29
  • 31. from django.contrib.auth.models import User from django.test import TestCase from django.core import mail class PasswordResetTest(TestCase): fixtures = ['authtestdata.json'] urls = 'django.contrib.auth.urls' def test_email_not_found(self): quot;Error is raised if the provided email address isn't currently registeredquot; response = self.client.get('/password_reset/') self.assertEquals(response.status_code, 200) response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'}) self.assertContains(response, quot;That e-mail address doesn&#39;t have an associated user accountquot;) self.assertEquals(len(mail.outbox), 0) Tuesday, May 5, 2009 30
  • 32. What flavor of test? • Unit • Functional • Browser Tuesday, May 5, 2009 31
  • 33. Unit test • Low level tests • Small, focused, exercising one bit of functionality Tuesday, May 5, 2009 32
  • 34. Regression test • Written when you find a bug • Proves bug was fixed • Django Tickets Tuesday, May 5, 2009 33
  • 35. Functional • “Black Box Testing” • Check High Level Functionality Tuesday, May 5, 2009 34
  • 36. Functional Testing Tools • Twill • Django Test Client • ... Tuesday, May 5, 2009 35
  • 37. Ellington • Lots of different clients • Need to test deployment (Functional) Tuesday, May 5, 2009 36
  • 38. go {{ site.url }}/marketplace/search/ formvalue 1 q pizza submit code 200 Tuesday, May 5, 2009 37
  • 39. Tuesday, May 5, 2009 38
  • 41. Can test • All sites on a server • All sites of a certain type • A single problemed client • A test across all sites Tuesday, May 5, 2009 40
  • 42. Browser tests • Run tests in a web browser • Check compatibility of design • Basically an IE sanity check • Only real way to test JS, AJAX, CSS Tuesday, May 5, 2009 41
  • 43. Browser Testing Tools • Windmill • Selenium Tuesday, May 5, 2009 42
  • 44. Tuesday, May 5, 2009 43
  • 45. Other kinds of testing • Spiders • Fuzz testing • Load testing • Prayer Tuesday, May 5, 2009 44
  • 46. Where do I start? Tuesday, May 5, 2009 45
  • 47. Fixed a bug Tuesday, May 5, 2009 46
  • 48. Poking at code on the command line Tuesday, May 5, 2009 47
  • 49. Pony turned Horse Tuesday, May 5, 2009 48
  • 51. Start with a regression test or a functional test Tuesday, May 5, 2009 50
  • 52. Use unittest unless you have a reason not to! Tuesday, May 5, 2009 51
  • 53. Use the data, Luke • Use data as a pivot • Fixtures means you use Unit Tests • Creation on the command line, Doctests Tuesday, May 5, 2009 52
  • 54. Creating Fixtures • ./manage.py dumpdata <app> • ./manage.py makefixture Model[x:y] • Follows relations • By Hand Tuesday, May 5, 2009 53
  • 55. TestShell ./manage.py testshell <fixture> Tuesday, May 5, 2009 54
  • 56. Making Functional tests • Usually a relatively annoying process • Testmaker makes it easy. • ./manage.py testmaker <app> • Simply browse and your session is recorded. Tuesday, May 5, 2009 55
  • 57. Testing your views generally gets you the most coverage. Tuesday, May 5, 2009 56
  • 58. 80% Case Tuesday, May 5, 2009 57
  • 59. When > Where Tuesday, May 5, 2009 58
  • 62. Tuesday, May 5, 2009 61
  • 63. Mock Objects • http://www.voidspace.org.uk/python/mock/ Tuesday, May 5, 2009 62
  • 64. import unittest from mock import Mock from templatetags.cms_tags import if_link_is_active, IsActiveNode class TestIsActiveTag(unittest.TestCase): def test_returns_correct_node_type(self): token = Mock(methods=['split_contents']) token.split_contents.return_value = ('if_link_is_active', 'bar') self.assertEqual(type(if_link_is_active(Mock(), token)), IsActiveNode) Tuesday, May 5, 2009 63
  • 66. Django Test Extensions • Gareth Rushgrove • Extra Assertions • Coverage and XML Test Runners • http://github.com/garethr/django-test-extensions Tuesday, May 5, 2009 65
  • 67. Django Sane Testing • Ella Folk, Lucas (Hi!) • Based on nosetests • Selenium • Live server • http://devel.almad.net/trac/django-sane-testing/ Tuesday, May 5, 2009 66
  • 68. Django Test Utils • Mine! • Testmaker • Crawler • Random fanciness • http://github.com/ericholscher/django-test-utils/tree/ master Tuesday, May 5, 2009 67
  • 69. Recording tests is generally seen as bad. Tuesday, May 5, 2009 68
  • 70. My philosophy • Write tests. • Notice patterns and best practices • Automate recording of tests with those patterns • If you can’t automate, use tools to make it easier. Tuesday, May 5, 2009 69
  • 71. Process for testmaker • Most view tests check status_code and response context • Write middleware that catches this info • Records it to a file • Err on the side of more data. Tuesday, May 5, 2009 70
  • 72. Goals (That perfect world) Tuesday, May 5, 2009 71
  • 73. Some form of TDD • Write tests as you write code • Makes your code easy to test Tuesday, May 5, 2009 72
  • 74. Follow Django’s Model • Tests with every commit • Docs with every commit • Run tests before commiting Tuesday, May 5, 2009 73
  • 75. Use a DVCS • At work we have a central SVN repo • Git feature branches • Code is staged for documentation and testing • Committed to SVN once it is “done” Tuesday, May 5, 2009 74
  • 77. NEVER LEAVE THE BUILD BROKEN Tuesday, May 5, 2009 76
  • 81. Profiling python -m cProfile manage.py test Tuesday, May 5, 2009 80
  • 82. Mock Objects http://www.voidspace.org.uk/python/mock/ Tuesday, May 5, 2009 81
  • 83. Future and Ponies Tuesday, May 5, 2009 82
  • 84. Summer of Code • Test-Only Models • Coverage • Windmill tests of the admin Tuesday, May 5, 2009 83
  • 85. Test Suites in Django Tuesday, May 5, 2009 84
  • 86. Central Testing Repository Tuesday, May 5, 2009 85
  • 88. Things to remember • Testing is not hard, you just have to get started. • If your code doesn’t have tests, it will be hard/ impossible to refactor • Once you have tests, you need to run them! Tuesday, May 5, 2009 87
  • 89. Credits • http://www.flickr.com/photos/tym/192416981/ • http://www.flickr.com/photos/seandreilinger/2459266781/ • http://www.homebabysafety.com/images/baby_crawl_suit.jpg • http://www.flickr.com/photos/pinkypigs/960572985/ Tuesday, May 5, 2009 88