SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Kata TDD
Jorge D. Ortiz Fuentes
@jdortiz
Parte 1:
Pruebas del modelo
Aviso para navegantes
★Esto no es una clase, sino
una experiencia compartida.
★Si compartes, aprendemos
todos.
★Si algo no te gusta, ofrece
tus alternativas.
3
¿TDD?
★Test Driven Development
★Es una forma de escribir
software
★Supone pensar primero en la
verificación del código y
luego en escribirlo
4
¿Por qué TDD?
★Codigo que hace lo que
pensamos.
★Programar en piloto
automático.
★Progreso medible.
★Mucho más fácil abordar
cambios.
5
Secuencia de trabajo
★Siguiente funcionalidad
★Escribir la prueba
★Escribir el código más simple
que pasa la prueba
★Refactorizar
★Repetir hasta acabar cada
historia
6
Código más corto
1.Más fijado (hard coded)
2.Más cerca del principio del
método
3.Menos sangrado (indented)
4.Más corto
7
Texto
http://osherove.com/blog/2010/1/6/tdd-4-questions-that-
will-help-you-create-the-simplest-thing.html
Las herramientas
★Introspección (OCUnit)
★Inyección de dependencias
๏Constructor
๏Propiedades
★Mocks y stubs
8
Las reglas del juego
★Sólo probamos nuestro código
★Sólo un nivel cada vez
★Sólo los métodos públicos
★Sólo una cosa en cada prueba
★Las pruebas son
independientes unas de otras
(ni secuencia, ni estado)
9
Algunos trucos
★Usar sut = reutilizar pruebas
★Confirmar que no hay avisos o
errores
★Separar en clases
★Refactorizar las pruebas
cuando interese
10
Inconvenientes
★ Más lento y más trabajo en calidad
★ Diseño sin visión de conjunto
★ Reescribir pruebas al cambiar
requisitos
★ Se requieren otras pruebas además
★ Mismas carencias las pruebas que
el código (sistema que no puede
entenderse a sí mismo, W.E.Deming)
11
Ventajas
★ Menos interactuación y menos
tiempo depurando
★ Más facil adaptarse a los cambios
★ Documentación en código y menos
asunciones.
★ Cobertura prácticamente total
12
Parte 2:
Pruebas de VC
Interfaz de la app
★Maestro/detalle
๏Maestro: Mezclas agrupadas por
categorías
๏Detalle: Mezcla y sus datos
14
View ctlr maestro
★BlendsViewController
★Lista (subclase de
UITableViewController)
15
View ctrlr detalle
★BlendDetailsViewController
★Subclase de UIViewController
16
A tener en cuenta
★Problemas con OCMock de Core
Data (NSProxy)
★No todos los métodos están
pensados para ser probados
(KVC al rescate)
17
Parte 3:
Código de otros
Modelo de trabajo
1.Leer el código
2.Pensar una prueba que
confirma cómo funciona
3.Escribirla y ver que la pasa
4.Refactorizar si procede.
5.Repetir
19
Código limpio
★Aprovechar para limpiar el
código
★Eliminar repetición y ganar
consistencia
★Sólo un nivel de abstracción
por método
20
¡Gracias!

Más contenido relacionado

La actualidad más candente

Como hacer tdd y no morir en el intento
Como hacer tdd y no morir en el intentoComo hacer tdd y no morir en el intento
Como hacer tdd y no morir en el intentoHernan Wilkinson
 
Cómo aplicar TDD. Almería 13/05/2014
Cómo aplicar TDD. Almería 13/05/2014Cómo aplicar TDD. Almería 13/05/2014
Cómo aplicar TDD. Almería 13/05/2014Javier_J
 
TDD 101 - Introducción al Desarrollo Dirigido por Pruebas
TDD 101 - Introducción al Desarrollo Dirigido por PruebasTDD 101 - Introducción al Desarrollo Dirigido por Pruebas
TDD 101 - Introducción al Desarrollo Dirigido por PruebasOrlando Bustos Mateluna
 
Si te gusta leer te va a gustar el software libre
Si te gusta leer te va a gustar el software libreSi te gusta leer te va a gustar el software libre
Si te gusta leer te va a gustar el software libreIBM
 
Crowdar - Introducción a BDD
Crowdar - Introducción a BDDCrowdar - Introducción a BDD
Crowdar - Introducción a BDDJavier Re
 
Agile university day - Un día en un equipo ágil de desarrollo móvil
Agile university day - Un día en un equipo ágil de desarrollo móvilAgile university day - Un día en un equipo ágil de desarrollo móvil
Agile university day - Un día en un equipo ágil de desarrollo móvilagilenavarra
 
PHP Unit y TDD
PHP Unit y TDDPHP Unit y TDD
PHP Unit y TDDEmergya
 
Encadenamiento de refactorings para generar cambios Agiles de Diseño
Encadenamiento de refactorings para generar cambios Agiles de DiseñoEncadenamiento de refactorings para generar cambios Agiles de Diseño
Encadenamiento de refactorings para generar cambios Agiles de DiseñoHernan Wilkinson
 
Análisis estático de código en Java
Análisis estático de código en JavaAnálisis estático de código en Java
Análisis estático de código en JavaCésar Hernández
 

La actualidad más candente (15)

Como hacer tdd y no morir en el intento
Como hacer tdd y no morir en el intentoComo hacer tdd y no morir en el intento
Como hacer tdd y no morir en el intento
 
Cómo aplicar TDD. Almería 13/05/2014
Cómo aplicar TDD. Almería 13/05/2014Cómo aplicar TDD. Almería 13/05/2014
Cómo aplicar TDD. Almería 13/05/2014
 
TDD 101 - Introducción al Desarrollo Dirigido por Pruebas
TDD 101 - Introducción al Desarrollo Dirigido por PruebasTDD 101 - Introducción al Desarrollo Dirigido por Pruebas
TDD 101 - Introducción al Desarrollo Dirigido por Pruebas
 
Si te gusta leer te va a gustar el software libre
Si te gusta leer te va a gustar el software libreSi te gusta leer te va a gustar el software libre
Si te gusta leer te va a gustar el software libre
 
Introducción a tdd
Introducción a tddIntroducción a tdd
Introducción a tdd
 
Crowdar - Introducción a BDD
Crowdar - Introducción a BDDCrowdar - Introducción a BDD
Crowdar - Introducción a BDD
 
Agile university day - Un día en un equipo ágil de desarrollo móvil
Agile university day - Un día en un equipo ágil de desarrollo móvilAgile university day - Un día en un equipo ágil de desarrollo móvil
Agile university day - Un día en un equipo ágil de desarrollo móvil
 
PHP Unit y TDD
PHP Unit y TDDPHP Unit y TDD
PHP Unit y TDD
 
Excepciones en java
Excepciones en javaExcepciones en java
Excepciones en java
 
Cobertura de pruebas unitarias - NetBaires
Cobertura de pruebas unitarias - NetBairesCobertura de pruebas unitarias - NetBaires
Cobertura de pruebas unitarias - NetBaires
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Seminario SOLID-TDD
Seminario SOLID-TDDSeminario SOLID-TDD
Seminario SOLID-TDD
 
Git y github
Git y githubGit y github
Git y github
 
Encadenamiento de refactorings para generar cambios Agiles de Diseño
Encadenamiento de refactorings para generar cambios Agiles de DiseñoEncadenamiento de refactorings para generar cambios Agiles de Diseño
Encadenamiento de refactorings para generar cambios Agiles de Diseño
 
Análisis estático de código en Java
Análisis estático de código en JavaAnálisis estático de código en Java
Análisis estático de código en Java
 

Destacado

Charla Tdd Uji 032010
Charla Tdd Uji 032010Charla Tdd Uji 032010
Charla Tdd Uji 032010Carlos Ble
 
Breve introducción a TDD con Phpunit
Breve introducción a TDD con PhpunitBreve introducción a TDD con Phpunit
Breve introducción a TDD con Phpunitmoisesgallego
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mockingKonstantin Kudryashov
 
Introduccion a TDD y XP en la Universidad de Santiago de Compostela
Introduccion a TDD y XP en la Universidad de Santiago de CompostelaIntroduccion a TDD y XP en la Universidad de Santiago de Compostela
Introduccion a TDD y XP en la Universidad de Santiago de CompostelaCarlos Ble
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 

Destacado (6)

Charla Tdd Uji 032010
Charla Tdd Uji 032010Charla Tdd Uji 032010
Charla Tdd Uji 032010
 
Breve introducción a TDD con Phpunit
Breve introducción a TDD con PhpunitBreve introducción a TDD con Phpunit
Breve introducción a TDD con Phpunit
 
TDD Course (Spanish)
TDD Course (Spanish)TDD Course (Spanish)
TDD Course (Spanish)
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 
Introduccion a TDD y XP en la Universidad de Santiago de Compostela
Introduccion a TDD y XP en la Universidad de Santiago de CompostelaIntroduccion a TDD y XP en la Universidad de Santiago de Compostela
Introduccion a TDD y XP en la Universidad de Santiago de Compostela
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 

Similar a Kata tdd

Las Claves del Desarrollo Dirigido por Pruebas (o TDD)
Las Claves del Desarrollo Dirigido por Pruebas (o TDD)Las Claves del Desarrollo Dirigido por Pruebas (o TDD)
Las Claves del Desarrollo Dirigido por Pruebas (o TDD)Javier_J
 
Introducción a Test Driven Development en PHPSevilla
Introducción a Test Driven Development en PHPSevillaIntroducción a Test Driven Development en PHPSevilla
Introducción a Test Driven Development en PHPSevillaJesús López de la Cruz
 
TDD y Python
TDD y PythonTDD y Python
TDD y PythonJavier_J
 
Introducción al Test-Driven Development (TDD) por Eric Mignot
Introducción al Test-Driven Development (TDD) por Eric MignotIntroducción al Test-Driven Development (TDD) por Eric Mignot
Introducción al Test-Driven Development (TDD) por Eric MignotPablo Lischinsky
 
"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturinowebcat
 
[ES] webcat 2014-03 Demystifying Development Techniques
[ES] webcat 2014-03 Demystifying Development Techniques[ES] webcat 2014-03 Demystifying Development Techniques
[ES] webcat 2014-03 Demystifying Development TechniquesEduardo Turiño
 
Introducción a TDD
Introducción a TDDIntroducción a TDD
Introducción a TDDFran Grau
 
Apuntes #XPweek
Apuntes #XPweekApuntes #XPweek
Apuntes #XPweekCarlos Ble
 
Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Javier Morales
 
Artalde Tdd intro
Artalde Tdd introArtalde Tdd intro
Artalde Tdd introfperezplain
 
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebas
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebasCodemotion 2013 - Desarrollo de videojuegos dirigido por pruebas
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebasJavier_J
 
Clean code 9
Clean code 9Clean code 9
Clean code 9540deg
 
Scrum Con Exito
Scrum Con ExitoScrum Con Exito
Scrum Con Exitojsalvata
 

Similar a Kata tdd (20)

Las Claves del Desarrollo Dirigido por Pruebas (o TDD)
Las Claves del Desarrollo Dirigido por Pruebas (o TDD)Las Claves del Desarrollo Dirigido por Pruebas (o TDD)
Las Claves del Desarrollo Dirigido por Pruebas (o TDD)
 
Tdd desde las_trincheras
Tdd desde las_trincherasTdd desde las_trincheras
Tdd desde las_trincheras
 
Introducción a Test Driven Development en PHPSevilla
Introducción a Test Driven Development en PHPSevillaIntroducción a Test Driven Development en PHPSevilla
Introducción a Test Driven Development en PHPSevilla
 
TDD y Python
TDD y PythonTDD y Python
TDD y Python
 
Introducción al Test-Driven Development (TDD) por Eric Mignot
Introducción al Test-Driven Development (TDD) por Eric MignotIntroducción al Test-Driven Development (TDD) por Eric Mignot
Introducción al Test-Driven Development (TDD) por Eric Mignot
 
"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino
 
Introducción a TDD
Introducción a TDDIntroducción a TDD
Introducción a TDD
 
[ES] webcat 2014-03 Demystifying Development Techniques
[ES] webcat 2014-03 Demystifying Development Techniques[ES] webcat 2014-03 Demystifying Development Techniques
[ES] webcat 2014-03 Demystifying Development Techniques
 
El arte de programar
El arte de programarEl arte de programar
El arte de programar
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Introducción a TDD
Introducción a TDDIntroducción a TDD
Introducción a TDD
 
TDD
TDDTDD
TDD
 
Apuntes #XPweek
Apuntes #XPweekApuntes #XPweek
Apuntes #XPweek
 
Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01
 
Artalde Tdd intro
Artalde Tdd introArtalde Tdd intro
Artalde Tdd intro
 
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebas
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebasCodemotion 2013 - Desarrollo de videojuegos dirigido por pruebas
Codemotion 2013 - Desarrollo de videojuegos dirigido por pruebas
 
Clean code 9
Clean code 9Clean code 9
Clean code 9
 
Creando rascacielos con tdd
Creando rascacielos con tddCreando rascacielos con tdd
Creando rascacielos con tdd
 
Scrum Con Exito
Scrum Con ExitoScrum Con Exito
Scrum Con Exito
 
7iSF-4 test driver development
7iSF-4   test driver development7iSF-4   test driver development
7iSF-4 test driver development
 

Más de Jorge Ortiz

Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsJorge Ortiz
 
Unit Test your Views
Unit Test your ViewsUnit Test your Views
Unit Test your ViewsJorge Ortiz
 
Control your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritJorge Ortiz
 
Kata gilded rose en Golang
Kata gilded rose en GolangKata gilded rose en Golang
Kata gilded rose en GolangJorge Ortiz
 
CYA: Cover Your App
CYA: Cover Your AppCYA: Cover Your App
CYA: Cover Your AppJorge Ortiz
 
Refactor your way forward
Refactor your way forwardRefactor your way forward
Refactor your way forwardJorge Ortiz
 
201710 Fly Me to the View - iOS Conf SG
201710 Fly Me to the View - iOS Conf SG201710 Fly Me to the View - iOS Conf SG
201710 Fly Me to the View - iOS Conf SGJorge Ortiz
 
Home Improvement: Architecture & Kotlin
Home Improvement: Architecture & KotlinHome Improvement: Architecture & Kotlin
Home Improvement: Architecture & KotlinJorge Ortiz
 
Architectural superpowers
Architectural superpowersArchitectural superpowers
Architectural superpowersJorge Ortiz
 
Architecting Alive Apps
Architecting Alive AppsArchitecting Alive Apps
Architecting Alive AppsJorge Ortiz
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editionJorge Ortiz
 
Android clean architecture workshop 3h edition
Android clean architecture workshop 3h editionAndroid clean architecture workshop 3h edition
Android clean architecture workshop 3h editionJorge Ortiz
 
To Protect & To Serve
To Protect & To ServeTo Protect & To Serve
To Protect & To ServeJorge Ortiz
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshopJorge Ortiz
 
Escape from Mars
Escape from MarsEscape from Mars
Escape from MarsJorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureJorge Ortiz
 
Dependence day insurgence
Dependence day insurgenceDependence day insurgence
Dependence day insurgenceJorge Ortiz
 
Architectural superpowers
Architectural superpowersArchitectural superpowers
Architectural superpowersJorge Ortiz
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the massesJorge Ortiz
 
7 Stages of Unit Testing in iOS
7 Stages of Unit Testing in iOS7 Stages of Unit Testing in iOS
7 Stages of Unit Testing in iOSJorge Ortiz
 

Más de Jorge Ortiz (20)

Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
 
Unit Test your Views
Unit Test your ViewsUnit Test your Views
Unit Test your Views
 
Control your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene Gesserit
 
Kata gilded rose en Golang
Kata gilded rose en GolangKata gilded rose en Golang
Kata gilded rose en Golang
 
CYA: Cover Your App
CYA: Cover Your AppCYA: Cover Your App
CYA: Cover Your App
 
Refactor your way forward
Refactor your way forwardRefactor your way forward
Refactor your way forward
 
201710 Fly Me to the View - iOS Conf SG
201710 Fly Me to the View - iOS Conf SG201710 Fly Me to the View - iOS Conf SG
201710 Fly Me to the View - iOS Conf SG
 
Home Improvement: Architecture & Kotlin
Home Improvement: Architecture & KotlinHome Improvement: Architecture & Kotlin
Home Improvement: Architecture & Kotlin
 
Architectural superpowers
Architectural superpowersArchitectural superpowers
Architectural superpowers
 
Architecting Alive Apps
Architecting Alive AppsArchitecting Alive Apps
Architecting Alive Apps
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h edition
 
Android clean architecture workshop 3h edition
Android clean architecture workshop 3h editionAndroid clean architecture workshop 3h edition
Android clean architecture workshop 3h edition
 
To Protect & To Serve
To Protect & To ServeTo Protect & To Serve
To Protect & To Serve
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
 
Escape from Mars
Escape from MarsEscape from Mars
Escape from Mars
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
 
Dependence day insurgence
Dependence day insurgenceDependence day insurgence
Dependence day insurgence
 
Architectural superpowers
Architectural superpowersArchitectural superpowers
Architectural superpowers
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the masses
 
7 Stages of Unit Testing in iOS
7 Stages of Unit Testing in iOS7 Stages of Unit Testing in iOS
7 Stages of Unit Testing in iOS
 

Kata tdd