Tdd with-python-and-django

Flavian Missi
Flavian MissiSoftware Developer at Orange Cyberdefense
Test Driven Development
with Python and Django
Who the F**lavia?
Agenda
1. Good code and bad code
2. What is TDD?
3. Why TDD?
4. How to TDD?
5. Continuous Integration
good code and bad code
Tdd with-python-and-django
undead code
what is TDD?
Tdd with-python-and-django
why TDD?
Tdd with-python-and-django
testing for design
Tdd with-python-and-django
Tdd with-python-and-django
how to TDD?
Tdd with-python-and-django
“You are not allowed to write any production
code unless it is to make a failing test pass.”
“You are not allowed to write any more of a test
than is sufficient to fail; and compilation failures
are failures.”
“You are not allowed to write any more
production code than is sufficient to pass the
one failing test.”
testing smells
def test_should_request_and_be_success(self):
response = self.client.get(“/posts”)
self.assertEqual(200, response.status_code)
def test_should_have_posts_on_ctx(self):
response = self.client.get(“/posts”)
self.assertIn(“posts”, response.context_data)
def test_should_list_posts_in_chronological_order(self):
r = self.client.get(“/posts”)
expected_posts = [p1, p2, p3, p4] # keep the order
self.assertQuerySetEqual(r.context_data[“posts”],
expected_posts)
Tools
● unittest
● django.test.TestCase
● nose
● py.test
● ...
CI - Continuous Integration
● drone.io
● travisci
● circleci
● jenkins
● hudson
● ...
Tack så mycket!
Flavia Missi
@flaviamissi
https://github.com/flaviamissi
Tack så mycket!
● http://butunclebob.com/ArticleS.UncleBob.
TheThreeRulesOfTdd
● http://butunclebob.com/ArticleS.UncleBob.
TheBowlingGameKata
● http://extremeprogramming.org/
1 of 26

Recommended

Acceptance Test Driven Development and Robot Framework by
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkSteve Zhang
4.2K views17 slides
Tdd in php a brief example by
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
2.1K views16 slides
Tdd com Java by
Tdd com JavaTdd com Java
Tdd com JavaRafael Miceli
563 views17 slides
Code review by
Code reviewCode review
Code reviewdqpi
2K views19 slides
Code Review by
Code ReviewCode Review
Code ReviewLukas Rypl
778 views27 slides
Binary Studio Academy: .NET Code Testing by
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio
261 views16 slides

More Related Content

What's hot

Code review by
Code reviewCode review
Code reviewAbhishek Sur
5K views19 slides
Tdd on play framework by
Tdd on play frameworkTdd on play framework
Tdd on play frameworkvuhaininh88
370 views23 slides
Speed up your tests by
Speed up your testsSpeed up your tests
Speed up your testsDevi Sridharan
258 views12 slides
Code Review by
Code ReviewCode Review
Code ReviewR M Shahidul Islam Shahed
191 views17 slides
TDD with Ruby by
TDD with RubyTDD with Ruby
TDD with RubyIsmael G Marín C
98 views10 slides
Code Review by
Code ReviewCode Review
Code ReviewDivante
773 views12 slides

What's hot(19)

Tdd on play framework by vuhaininh88
Tdd on play frameworkTdd on play framework
Tdd on play framework
vuhaininh88370 views
Code Review by Divante
Code ReviewCode Review
Code Review
Divante773 views
Code Review by Tu Hoang
Code ReviewCode Review
Code Review
Tu Hoang1.2K views
eXtreme readable Acceptance Testing by Alex Fernandez
eXtreme readable Acceptance TestingeXtreme readable Acceptance Testing
eXtreme readable Acceptance Testing
Alex Fernandez111 views
Test Driven Development Powered by LEGO by Agile Montréal
Test Driven Development Powered by LEGOTest Driven Development Powered by LEGO
Test Driven Development Powered by LEGO
Agile Montréal1.4K views
Testing the untestable by RoyKlein
Testing the untestableTesting the untestable
Testing the untestable
RoyKlein990 views
Code Review: How and When by Paul Gower
Code Review: How and WhenCode Review: How and When
Code Review: How and When
Paul Gower326 views
Code Review Best Practices by Trisha Gee
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
Trisha Gee4.3K views
Performance profiling and testing of symfony application 2 by Andrew Yatsenko
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
Andrew Yatsenko1.6K views
Code Review: How and When by Paul Gower
Code Review: How and WhenCode Review: How and When
Code Review: How and When
Paul Gower687 views

Similar to Tdd with-python-and-django

Tdd red-green-refactor by
Tdd red-green-refactorTdd red-green-refactor
Tdd red-green-refactorFrancisco Iglesias Gómez
244 views22 slides
Test-Driven Development Reference Card by
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference CardSeapine Software
557 views2 slides
Test Driven Development and Automation by
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and AutomationMahesh Salaria
4.5K views27 slides
Test Driven Development by
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
342 views17 slides
Effective TDD - Less is more by
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is moreBen Lau
1.6K views35 slides
Test Driven Development by
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentSachithra Gayan
1.8K views15 slides

Similar to Tdd with-python-and-django(20)

Test-Driven Development Reference Card by Seapine Software
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
Seapine Software557 views
Test Driven Development and Automation by Mahesh Salaria
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
Mahesh Salaria4.5K views
Test Driven Development by bhochhi
Test Driven DevelopmentTest Driven Development
Test Driven Development
bhochhi342 views
Effective TDD - Less is more by Ben Lau
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is more
Ben Lau1.6K views
Test-Driven Development In Action by Jon Kruger
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
Jon Kruger4.4K views
Pair programming and introduction to TDD by Arati Joshi
Pair programming and introduction to TDDPair programming and introduction to TDD
Pair programming and introduction to TDD
Arati Joshi58 views
Understanding Why Testing is Importaint by Sana Nasar
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
Sana Nasar694 views
Workshop quality assurance for php projects - phpdublin by Michelangelo van Dam
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublin
TDD in PHP - Memphis PHP 2011-08-25 by Jeremy Kendall
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
Jeremy Kendall1.5K views
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019 by Jason Tice
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Jason Tice132 views
Test Driven Development by jakubkoci
Test Driven DevelopmentTest Driven Development
Test Driven Development
jakubkoci284 views
Test Driven Development with Laravel by Tyler Johnston
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
Tyler Johnston329 views

More from Flavian Missi

Profiling em Python by
Profiling em PythonProfiling em Python
Profiling em PythonFlavian Missi
713 views58 slides
Tsuru - plataforma de cloud computing open source by
Tsuru - plataforma de cloud computing open sourceTsuru - plataforma de cloud computing open source
Tsuru - plataforma de cloud computing open sourceFlavian Missi
885 views40 slides
Django class based-views by
Django class based-viewsDjango class based-views
Django class based-viewsFlavian Missi
665 views8 slides
Rails::Engine by
Rails::EngineRails::Engine
Rails::EngineFlavian Missi
800 views17 slides
Modularizing Rails Apps with Cells by
Modularizing Rails Apps with CellsModularizing Rails Apps with Cells
Modularizing Rails Apps with CellsFlavian Missi
1.7K views15 slides
Capybara by
CapybaraCapybara
CapybaraFlavian Missi
1.9K views21 slides

More from Flavian Missi(6)

Tsuru - plataforma de cloud computing open source by Flavian Missi
Tsuru - plataforma de cloud computing open sourceTsuru - plataforma de cloud computing open source
Tsuru - plataforma de cloud computing open source
Flavian Missi885 views
Django class based-views by Flavian Missi
Django class based-viewsDjango class based-views
Django class based-views
Flavian Missi665 views
Modularizing Rails Apps with Cells by Flavian Missi
Modularizing Rails Apps with CellsModularizing Rails Apps with Cells
Modularizing Rails Apps with Cells
Flavian Missi1.7K views

Recently uploaded

The Path to DevOps by
The Path to DevOpsThe Path to DevOps
The Path to DevOpsJohn Valentino
6 views6 slides
Introduction to Gradle by
Introduction to GradleIntroduction to Gradle
Introduction to GradleJohn Valentino
7 views7 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30Shane Coughlan
8 views18 slides
EV Charging App Case by
EV Charging App Case EV Charging App Case
EV Charging App Case iCoderz Solutions
10 views1 slide
Supercharging your Python Development Environment with VS Code and Dev Contai... by
Supercharging your Python Development Environment with VS Code and Dev Contai...Supercharging your Python Development Environment with VS Code and Dev Contai...
Supercharging your Python Development Environment with VS Code and Dev Contai...Dawn Wages
5 views51 slides
Winter Projects GDSC IITK by
Winter Projects GDSC IITKWinter Projects GDSC IITK
Winter Projects GDSC IITKSahilSingh368445
416 views60 slides

Recently uploaded(20)

FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan8 views
Supercharging your Python Development Environment with VS Code and Dev Contai... by Dawn Wages
Supercharging your Python Development Environment with VS Code and Dev Contai...Supercharging your Python Development Environment with VS Code and Dev Contai...
Supercharging your Python Development Environment with VS Code and Dev Contai...
Dawn Wages5 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino8 views
aATP - New Correlation Confirmation Feature.pptx by EsatEsenek1
aATP - New Correlation Confirmation Feature.pptxaATP - New Correlation Confirmation Feature.pptx
aATP - New Correlation Confirmation Feature.pptx
EsatEsenek1222 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67026 views
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile... by Stefan Wolpers
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
Stefan Wolpers44 views
JioEngage_Presentation.pptx by admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254559 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert35 views
predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app14 views
Automated Testing of Microsoft Power BI Reports by RTTS
Automated Testing of Microsoft Power BI ReportsAutomated Testing of Microsoft Power BI Reports
Automated Testing of Microsoft Power BI Reports
RTTS11 views
Mobile App Development Company by Richestsoft
Mobile App Development CompanyMobile App Development Company
Mobile App Development Company
Richestsoft 5 views

Tdd with-python-and-django