Django strategy-test

430 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
430
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Django strategy-test

  1. 1. A Testing Strategy in Django BY ROYCE HAYNES TWITTER: @ROYCEHAYNES
  2. 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. 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. 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. 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. 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. 7. Django Testing Strategy Unchained (show Django project)
  8. 8. Things to live by1. 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 run8. Be ready to throw away an entire day of changes.
  9. 9. Thank you. Questions? www.roycehaynes.com www.github.com/roycehaynes @roycehaynes on Twitter

×