Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing Django with Travis CI
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Adam McKerlie
November 11, 2012
Technology
760
2
Share
Testing Django with Travis CI
A talk I gave on testing Django and using Travis CI for Pycon Canada
Adam McKerlie
November 11, 2012
More Decks by Adam McKerlie
See All by Adam McKerlie
Getting Rid of Technical Debt
silent1mezzo
0
1.8k
Lessons Learned from a Re(design|write)
silent1mezzo
2
6.3k
Travis CI
silent1mezzo
7
4.6k
Other Decks in Technology
See All in Technology
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
1.3k
価格.comをAI駆動で全面刷新する ー 30年分の技術的負債を返し、次の30年の土台をつくる ー
tkyowa
5
2.5k
PHP と TypeScript の型システム比較:AI 時代の「型」は誰のためにあるのか? #frontend_phpcon_do / frontend_phpcon_do_2026
shogogg
1
230
OpenID Connectによるサービス間連携
takesection
0
150
Javaで学ぶSOLID原則
negima
1
260
Unlocking the Apps
pimterry
0
160
GoとSIMDとWasmの今。
askua
3
460
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
140
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
320
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
170
テストコードのないプロジェクトにテストを根付かせる
tttol
1
240
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
55
8.2k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Ethics towards AI in product and experience design
skipperchong
2
290
Paper Plane
katiecoart
PRO
1
51k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
260
The SEO Collaboration Effect
kristinabergwall1
1
470
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
200
The Mindset for Success: Future Career Progression
greggifford
PRO
0
350
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Transcript
TESTING DJANGO WITH TRAVIS CI 1 Sunday, November 11, 12
• Python Developer at • Twitter: @adammckerlie • Everywhere else:
silent1mezzo ABOUT ME 2 Sunday, November 11, 12
SLIDES bit.ly/UhvbjV 3 Sunday, November 11, 12
• Definitions • Why you should test your code •
What parts of your code you should test • Writing your first test • Integrating Travis CI to automatically run your tests OVERVIEW 4 Sunday, November 11, 12
UNIT TEST • Tests one small section of code •
Focuses your code • Fast 5 Sunday, November 11, 12
INTEGRATION TEST • Tests that the whole system works (views,
forms, etc...) • Slow • Gives you a full picture of what’s happening 6 Sunday, November 11, 12
• Gives you confidence in your code • Allows you
to iterate faster • Provides beginners an easy spot to code-dive • Untested code is expensive WHY YOU SHOULD WRITE TESTS 7 Sunday, November 11, 12
“CODE NOT TESTED IS BROKEN BY DESIGN” JACOB KAPLAN-MOSS 8
Sunday, November 11, 12
• Don’t test Django or Python’s built-in stuff • Test
your views, models, forms, management commands, etc... WHAT YOU SHOULD TEST 9 Sunday, November 11, 12
• Tests can go in models.py or tests.py • Must
subclass django.test.TestCase • python manage.py test <app_name> WRITING YOUR FIRST TEST 10 Sunday, November 11, 12
• Every view should have this test 11 Sunday, November
11, 12
• Fixtures are serialized data that you can load. •
python manage.py dumpdata app_name > app_name/fixtures/file.json USING FIXTURES 12 Sunday, November 11, 12
13 Sunday, November 11, 12
• After every commit • Before you merge your branches
into master • Once you’ve deployed your code WHEN SHOULD YOU TEST 14 Sunday, November 11, 12
WHAT IS TRAVIS-CI? • Continuous Integration Testing • Open Source
• https://github.com/travis-ci 15 Sunday, November 11, 12
+ = 16 Sunday, November 11, 12
HOW DOES IT WORK? • Sign up with your github
account • Specify repositories • Include a .travis.yml file • Change/commit/push code • Tests run automagically 17 Sunday, November 11, 12
18 Sunday, November 11, 12
.travis.yml 19 Sunday, November 11, 12
Environment Variables 20 Sunday, November 11, 12
Using Databases 21 Sunday, November 11, 12
PULL REQUESTS • Test Pull Requests before they’re merged to
master • Notifications of running tests • Notifications of successful tests 22 Sunday, November 11, 12
23 Sunday, November 11, 12
24 Sunday, November 11, 12
before/after_script 25 Sunday, November 11, 12
NOTIFICATIONS 26 Sunday, November 11, 12
Email Notifications 27 Sunday, November 11, 12
IRC Notifications 28 Sunday, November 11, 12
Webhook Notifications 29 Sunday, November 11, 12
FINAL TIPS • [ci skip] • https://secure.travis-ci.org/[YOUR_GITHUB_USERNAME]/ [YOUR_PROJECT_NAME].png • travis-lint
30 Sunday, November 11, 12
QUESTIONS? 31 Sunday, November 11, 12