SlideShare a Scribd company logo
TDD  in the  Web  with  Python XP Conference 2011 Carlos Blé www.carlosble.com @carlosble
The Architecture Ruby on Rails,  Django , Monorail, ASP.Net MVC, Spring MVC, Play Framework, Symphony, Zend Framework...
We like to think like this
Separate concerns Controller : Deals with the  browser .  Get the input, make some calls and return the output . It should be as  simple  as possible.  The less it knows about the domain, the better. View : Renders UI.  Doesn't know the domain at all!!! Domain : Deals with the  user . Business requirements.  Wouldn't be cool if we can exercise the domain using ”end-to-end” tests?
Test-driving Inside-out  (bottom-up) So we can test-drive the domain and invoke it from the controller after all, like this: Now we can write an integration test for this controller...  but integration tests are painful!
Is not that clean always  :-(
When the  controller  needs to  know Validation rules
How to parse complex data (forms)
Which UI to render for a given scenario We end up with a mess :-(
Test-driving Outside-in  (top-down) Integration tests are a scam. Let's go ” unit” We don't use Django's TestCase, but unittest's
Replacing with test doubles
Replace   conditional   with   polymorphism We can move conditionals from views to controllers

More Related Content

What's hot (20)

PDF
Padre user experience
Charlie Gonzalez
 
PDF
Automated Web Testing using JavaScript
Simon Guest
 
PDF
Ember.js Brussels Meetup #3 - Testing your Ember.js app
yoranbe
 
PDF
Introducing Ghost Inspector
Neil Mansilla
 
PDF
Automating android
Melvin Laguren
 
PPTX
Tdd final submission
harshit040591
 
PPTX
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
PPTX
Unit testing for User Interfaces
webmull
 
PPTX
Introduction to Integration Testing With Cypress
Erez Cohen
 
PDF
Introduction to Functional Reactive Programming
Đặng Thái Sơn
 
PDF
Increasing performance with Elixir Tasks
Jeffrey Chan
 
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
PDF
Making cross browser tests beautiful
Meaghan Lewis
 
PDF
Learn Elixir at Manchester Lambda Lounge
Chi-chi Ekweozor
 
PPTX
It's just Angular
Vinci Rufus
 
PDF
Play Framework
Eduard Tudenhoefner
 
PDF
AngularJS and Protractor
Filipe Falcão
 
PPTX
Angular Unit Testing
Shailendra Chauhan
 
PPTX
Async CTP 3 Presentation for MUGH 2012
Sri Kanth
 
KEY
Herding a Cat with Antlers - Catalyst 5.80
Tomas Doran
 
Padre user experience
Charlie Gonzalez
 
Automated Web Testing using JavaScript
Simon Guest
 
Ember.js Brussels Meetup #3 - Testing your Ember.js app
yoranbe
 
Introducing Ghost Inspector
Neil Mansilla
 
Automating android
Melvin Laguren
 
Tdd final submission
harshit040591
 
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
Unit testing for User Interfaces
webmull
 
Introduction to Integration Testing With Cypress
Erez Cohen
 
Introduction to Functional Reactive Programming
Đặng Thái Sơn
 
Increasing performance with Elixir Tasks
Jeffrey Chan
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
Making cross browser tests beautiful
Meaghan Lewis
 
Learn Elixir at Manchester Lambda Lounge
Chi-chi Ekweozor
 
It's just Angular
Vinci Rufus
 
Play Framework
Eduard Tudenhoefner
 
AngularJS and Protractor
Filipe Falcão
 
Angular Unit Testing
Shailendra Chauhan
 
Async CTP 3 Presentation for MUGH 2012
Sri Kanth
 
Herding a Cat with Antlers - Catalyst 5.80
Tomas Doran
 

Viewers also liked (20)

PPT
Big data amb Cassandra i Celery ##bbmnk
Santi Camps
 
PDF
The emerging world of mongo db csp
Carlos Sánchez Pérez
 
PDF
El arte oscuro de estimar v3
Leonardo Soto
 
PPT
Introduccio a python
Santi Camps
 
PDF
STM on PyPy
fcofdezc
 
ODP
Conferencia Big Data en #MenorcaConnecta
Santi Camps
 
ODP
Python 101
Julián Perelli
 
PPTX
Madrid SPARQL handson
Victor de Boer
 
PDF
Python and MongoDB
Norberto Leite
 
PDF
#DataBeers: Inmersive Data Visualization con Oculus Rift
Outliers Collective
 
PDF
A Folksonomy of styles, aka: other stylists also said and Subjective Influenc...
Natalia Díaz Rodríguez
 
PDF
Python Dominicana 059: Django Migrations
Rafael Belliard
 
PDF
10 cosas de rails que deberías saber
Carlos Sánchez Pérez
 
ODP
Transparencias taller Python
Sergio Soto
 
PDF
Knowing your garbage collector - PyCon Italy 2015
fcofdezc
 
PDF
Volunteering assistance to online geocoding services through a distributed kn...
José Pablo Gómez Barrón S.
 
PDF
Knowing your Garbage Collector / Python Madrid
fcofdezc
 
PDF
Tidy vews, decorator and presenter
Carlos Sánchez Pérez
 
PDF
BDD - Test Academy Barcelona 2017
Carlos Ble
 
Big data amb Cassandra i Celery ##bbmnk
Santi Camps
 
The emerging world of mongo db csp
Carlos Sánchez Pérez
 
El arte oscuro de estimar v3
Leonardo Soto
 
Introduccio a python
Santi Camps
 
STM on PyPy
fcofdezc
 
Conferencia Big Data en #MenorcaConnecta
Santi Camps
 
Python 101
Julián Perelli
 
Madrid SPARQL handson
Victor de Boer
 
Python and MongoDB
Norberto Leite
 
#DataBeers: Inmersive Data Visualization con Oculus Rift
Outliers Collective
 
A Folksonomy of styles, aka: other stylists also said and Subjective Influenc...
Natalia Díaz Rodríguez
 
Python Dominicana 059: Django Migrations
Rafael Belliard
 
10 cosas de rails que deberías saber
Carlos Sánchez Pérez
 
Transparencias taller Python
Sergio Soto
 
Knowing your garbage collector - PyCon Italy 2015
fcofdezc
 
Volunteering assistance to online geocoding services through a distributed kn...
José Pablo Gómez Barrón S.
 
Knowing your Garbage Collector / Python Madrid
fcofdezc
 
Tidy vews, decorator and presenter
Carlos Sánchez Pérez
 
BDD - Test Academy Barcelona 2017
Carlos Ble
 
Ad

Similar to TDD in the Web with Python and Django (20)

PDF
Testdriven Development With Python 1st Edition Harry J W Percival
ykvfacwe5221
 
PPTX
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
hemasubbu08
 
PPTX
Testing Django APIs
tyomo4ka
 
PDF
Python Testing 101 with Selenium
Leonardo Jimenez
 
PDF
Token Testing Slides
ericholscher
 
PDF
Automated Testing of Web Applications
jonatankronqvist
 
PPTX
Django strategy-test
Royce Haynes
 
PPTX
Beginners overview of automated testing with Rspec
jeffrey1ross
 
PDF
Testing Django Applications
Gareth Rushgrove
 
PDF
Tools. Techniques. Trouble?
Testplant
 
PDF
Web Application Testing with Selenium
Sargis Sargsyan
 
KEY
Graceful Failure with Selenium and Continuous Integration
Chris B. France
 
PDF
Testing Ember Apps
jo_liss
 
PDF
DIY in 5 Minutes: Testing Django App with Pytest
Inexture Solutions
 
PPTX
Addressing Security Regression Through Unit Testing
Christopher Grayson
 
ODP
Focus on the outside, testing in ASP.NET MVC
Rob Ashton
 
PDF
Introduction to Automated Testing
Lars Thorup
 
PDF
Introduction to-automated-testing
BestBrains
 
PPTX
Upstate CSCI 540 Unit testing
DanWooster1
 
PDF
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
Testdriven Development With Python 1st Edition Harry J W Percival
ykvfacwe5221
 
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
hemasubbu08
 
Testing Django APIs
tyomo4ka
 
Python Testing 101 with Selenium
Leonardo Jimenez
 
Token Testing Slides
ericholscher
 
Automated Testing of Web Applications
jonatankronqvist
 
Django strategy-test
Royce Haynes
 
Beginners overview of automated testing with Rspec
jeffrey1ross
 
Testing Django Applications
Gareth Rushgrove
 
Tools. Techniques. Trouble?
Testplant
 
Web Application Testing with Selenium
Sargis Sargsyan
 
Graceful Failure with Selenium and Continuous Integration
Chris B. France
 
Testing Ember Apps
jo_liss
 
DIY in 5 Minutes: Testing Django App with Pytest
Inexture Solutions
 
Addressing Security Regression Through Unit Testing
Christopher Grayson
 
Focus on the outside, testing in ASP.NET MVC
Rob Ashton
 
Introduction to Automated Testing
Lars Thorup
 
Introduction to-automated-testing
BestBrains
 
Upstate CSCI 540 Unit testing
DanWooster1
 
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
Ad

More from Carlos Ble (8)

PDF
Gestión de proyectos
Carlos Ble
 
PDF
Maintainable software
Carlos Ble
 
PDF
Carbon offsetting
Carlos Ble
 
PDF
Distinguir entre Problema y Solución
Carlos Ble
 
PDF
ES6 Simplified
Carlos Ble
 
PDF
Behavior Driven Development - Material de clase PMA
Carlos Ble
 
PDF
Apuntes #XPweek
Carlos Ble
 
ODP
Charla Tdd Uji 032010
Carlos Ble
 
Gestión de proyectos
Carlos Ble
 
Maintainable software
Carlos Ble
 
Carbon offsetting
Carlos Ble
 
Distinguir entre Problema y Solución
Carlos Ble
 
ES6 Simplified
Carlos Ble
 
Behavior Driven Development - Material de clase PMA
Carlos Ble
 
Apuntes #XPweek
Carlos Ble
 
Charla Tdd Uji 032010
Carlos Ble
 

Recently uploaded (20)

PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 

TDD in the Web with Python and Django

  • 1. TDD in the Web with Python XP Conference 2011 Carlos Blé www.carlosble.com @carlosble
  • 2. The Architecture Ruby on Rails, Django , Monorail, ASP.Net MVC, Spring MVC, Play Framework, Symphony, Zend Framework...
  • 3. We like to think like this
  • 4. Separate concerns Controller : Deals with the browser . Get the input, make some calls and return the output . It should be as simple as possible. The less it knows about the domain, the better. View : Renders UI. Doesn't know the domain at all!!! Domain : Deals with the user . Business requirements. Wouldn't be cool if we can exercise the domain using ”end-to-end” tests?
  • 5. Test-driving Inside-out (bottom-up) So we can test-drive the domain and invoke it from the controller after all, like this: Now we can write an integration test for this controller... but integration tests are painful!
  • 6. Is not that clean always :-(
  • 7. When the controller needs to know Validation rules
  • 8. How to parse complex data (forms)
  • 9. Which UI to render for a given scenario We end up with a mess :-(
  • 10. Test-driving Outside-in (top-down) Integration tests are a scam. Let's go ” unit” We don't use Django's TestCase, but unittest's
  • 12. Replace conditional with polymorphism We can move conditionals from views to controllers
  • 13. Replace conditional with polymorphism Django templates inheritance is so cool!!!
  • 14. Conclusions End-to-end tests for the domain, are cheaper excluding web concerns (controllers, UIs)
  • 15. Selenium (or Webdriver) tests are too fragile
  • 16. Test-driving controllers give us fast feedback
  • 17. So we recommend: Unit test the controllers (test-first)
  • 18. Unit test the domain (test-first)
  • 19. Write integration tests for DB access, etc
  • 20. Write end-to-end tests for the domain We don't use Django's TestCase, but unittest's