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
Adam McKerlie
November 11, 2012
Technology
2
730
Testing Django with Travis CI
A talk I gave on testing Django and using Travis CI for Pycon Canada
Adam McKerlie
November 11, 2012
Tweet
Share
More Decks by Adam McKerlie
See All by Adam McKerlie
Getting Rid of Technical Debt
silent1mezzo
0
1.7k
Lessons Learned from a Re(design|write)
silent1mezzo
2
6.3k
Travis CI
silent1mezzo
7
4.5k
Other Decks in Technology
See All in Technology
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
170
CDCL による厳密解法を採用した MILP ソルバー
imai448
4
390
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
330
型チェック 速度改善 奮闘記⌛
tocomi
2
360
もし大規模障害が、10分で解決できたら?
masaaki_k
0
110
コンパウンド戦略に向けた技術選定とリアーキテクチャ
kworkdev
PRO
1
2.5k
OOM発生時のトラブルシューティング Profilerを活用できるか調査してみた
atsushii
0
180
Taming you application's environments
salaboy
0
210
偶有的複雑性と戦うためのアーキテクチャとチームトポロジー
knih
7
3.6k
Amazon Forecast亡き今、我々がマネージドサービスに頼らず時系列予測を実行する方法
sadynitro
0
200
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
170
The Rise of LLMOps
asei
10
2.1k
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
A designer walks into a library…
pauljervisheath
204
24k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Documentation Writing (for coders)
carmenintech
65
4.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
1
170
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Designing for humans not robots
tammielis
250
25k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
17k
A Tale of Four Properties
chriscoyier
156
23k
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