SlideShare a Scribd company logo
A Testing Strategy in Django

         BY ROYCE HAYNES
      TWITTER: @ROYCEHAYNES
Why test your code?

 You need to verify that your code works.
   Does your code do what’s expected, and nothing else?

 Provide usage examples for the next guy.
   Can other developers see examples of how your code is used?

 Use your API before you make it.
   Map out how you would use code before writing it.

 Minimize mistakes, maximize productivity
   Writing tests saves time, money, and lives.
Types of Testing

 Unit Tests
   Goal: Interrogates a unit of your source code.
   Typically repeatable, consistent, and fast.
   Try to mock complex dependencies and interactions to the outside world.

 Regression Tests
   Goal: Verify that a bug never happens again.
   Fixes known software bugs.
   Uncovers new software bugs.

 Acceptance Tests
   Goal: Verify a feature is correctly implemented.

 Smoke Tests
   Goal: Ensure software and system doesn’t blow up.

 Load Tests
   Goal: Measure response times and performance of software and system.
Tools

 unittest package library
   Part of python’s core lib.
   Most used package for testing web applications.

 coverage.py
   Tool used to measure coverage of Python programs, not just Django.

 django.test
   Django.test is pretty much the unittest package library.

 nose
   Extends unittest lib and can make automated testing easier.

 django-discover-runner
   A python acceptance test tool for web applications.

 Jenkins CI
   Use to test and deploy code.

 Selenium
   Automate web application acceptance test.
What to test?

 Business logic
   Credit card processing

   Creating, updating, or removing database records

 Shady Code
   Shady code is untested code that appears confusing or looks
    wrong.
 Specific to Django
   Custom views and forms

   Overriding methods core to Django

   Code that relies on untested third-party packages (optional).
When should you test?

 Code a little, test a little (or vice versa)


 If you use version control system, successfully test
  code before pushing to remote repo.
Django Testing Strategy Unchained
           (show Django project)
Things to live by

1.   Something is better than nothing.
2.   Coverage isn’t everything.
3.   Be willing to invest in test fixtures.
4.   If you aren’t convinced on the value of testing, your
     team won’t be either.
5.   Harvest metrics.
6.   Capture bugs in an automated test.
7.   Pause to refactor when test suite takes too long to
     run
8.   Be ready to throw away an entire day of changes.
Thank you. Questions?

 www.roycehaynes.com


 www.github.com/roycehaynes


 @roycehaynes on Twitter

More Related Content

What's hot

Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
brian d foy
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
lyricnz
 
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
D
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
D
 
The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013
D
 

What's hot (20)

Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with PuppetIt Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress[English][Test Girls] Zero to Hero: Start Test automation with Cypress
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
 
Capybara testing
Capybara testingCapybara testing
Capybara testing
 
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
 
The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project Setup
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
 
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
 
The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013
 
Automating Perl deployments with Hudson
Automating Perl deployments with HudsonAutomating Perl deployments with Hudson
Automating Perl deployments with Hudson
 
Helpful Automation Techniques - Selenium Camp 2014
Helpful Automation Techniques - Selenium Camp 2014Helpful Automation Techniques - Selenium Camp 2014
Helpful Automation Techniques - Selenium Camp 2014
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
 
Testing In Django
Testing In DjangoTesting In Django
Testing In Django
 
Introduction to test_driven_development
Introduction to test_driven_developmentIntroduction to test_driven_development
Introduction to test_driven_development
 
Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)
 
Continuous delivery - tools and techniques
Continuous delivery - tools and techniquesContinuous delivery - tools and techniques
Continuous delivery - tools and techniques
 
Getting started with Octopus Deploy
Getting started with Octopus DeployGetting started with Octopus Deploy
Getting started with Octopus Deploy
 
Automated Testing Environment by Bugzilla, Testopia and Jenkins
Automated Testing Environment by Bugzilla, Testopia and JenkinsAutomated Testing Environment by Bugzilla, Testopia and Jenkins
Automated Testing Environment by Bugzilla, Testopia and Jenkins
 

Similar to Django strategy-test

stm f.pdf
stm f.pdfstm f.pdf
stm f.pdf
HarshNagda5
 

Similar to Django strategy-test (20)

Types of testing
Types of testingTypes of testing
Types of testing
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
 
DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest
 
Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Software coding and testing
Software coding and testingSoftware coding and testing
Software coding and testing
 
Myths and reality about software testing
Myths and reality about software testingMyths and reality about software testing
Myths and reality about software testing
 
Topic production code
Topic production codeTopic production code
Topic production code
 
TEA Presentation V 0.3
TEA Presentation V 0.3TEA Presentation V 0.3
TEA Presentation V 0.3
 
Test driven development(tdd)
Test driven development(tdd)Test driven development(tdd)
Test driven development(tdd)
 
National 5 Computing Science - Testing
National 5 Computing Science - TestingNational 5 Computing Science - Testing
National 5 Computing Science - Testing
 
Software presentation
Software presentationSoftware presentation
Software presentation
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
Testing Hourglass at Jira Frontend - by Alexey Shpakov, Sr. Developer @ Atlas...
 
Tdd
TddTdd
Tdd
 
Testing strategies
Testing strategiesTesting strategies
Testing strategies
 
Automated tests
Automated testsAutomated tests
Automated tests
 
Software testing methods
Software testing methodsSoftware testing methods
Software testing methods
 
stm f.pdf
stm f.pdfstm f.pdf
stm f.pdf
 

Django strategy-test

  • 1. A Testing Strategy in Django BY ROYCE HAYNES TWITTER: @ROYCEHAYNES
  • 2. Why test your code?  You need to verify that your code works.  Does your code do what’s expected, and nothing else?  Provide usage examples for the next guy.  Can other developers see examples of how your code is used?  Use your API before you make it.  Map out how you would use code before writing it.  Minimize mistakes, maximize productivity  Writing tests saves time, money, and lives.
  • 3. Types of Testing  Unit Tests  Goal: Interrogates a unit of your source code.  Typically repeatable, consistent, and fast.  Try to mock complex dependencies and interactions to the outside world.  Regression Tests  Goal: Verify that a bug never happens again.  Fixes known software bugs.  Uncovers new software bugs.  Acceptance Tests  Goal: Verify a feature is correctly implemented.  Smoke Tests  Goal: Ensure software and system doesn’t blow up.  Load Tests  Goal: Measure response times and performance of software and system.
  • 4. Tools  unittest package library  Part of python’s core lib.  Most used package for testing web applications.  coverage.py  Tool used to measure coverage of Python programs, not just Django.  django.test  Django.test is pretty much the unittest package library.  nose  Extends unittest lib and can make automated testing easier.  django-discover-runner  A python acceptance test tool for web applications.  Jenkins CI  Use to test and deploy code.  Selenium  Automate web application acceptance test.
  • 5. What to test?  Business logic  Credit card processing  Creating, updating, or removing database records  Shady Code  Shady code is untested code that appears confusing or looks wrong.  Specific to Django  Custom views and forms  Overriding methods core to Django  Code that relies on untested third-party packages (optional).
  • 6. When should you test?  Code a little, test a little (or vice versa)  If you use version control system, successfully test code before pushing to remote repo.
  • 7. Django Testing Strategy Unchained (show Django project)
  • 8. Things to live by 1. Something is better than nothing. 2. Coverage isn’t everything. 3. Be willing to invest in test fixtures. 4. If you aren’t convinced on the value of testing, your team won’t be either. 5. Harvest metrics. 6. Capture bugs in an automated test. 7. Pause to refactor when test suite takes too long to run 8. Be ready to throw away an entire day of changes.
  • 9. Thank you. Questions?  www.roycehaynes.com  www.github.com/roycehaynes  @roycehaynes on Twitter