SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Taller de Unit Testing
y TDD en Java
Parte 1




Jano González
Desarrollador
Parte 1
●   Iremos desde la práctica hacia la teoría:
    ●   Uso de JUnit 4
    ●   Matchers básicos
    ●   Ejemplo simple (demasiado?) de TDD
Parte 2
●   Próximo L&B
●   Iremos desde la práctica hacia la teoría:
    ●   Otros matchers
    ●   Mock objects
    ●   Ejemplo de TDD
    ●   Cómo hacer buenos tests
Parte N
●   Si les interesa podemos hacer más talleres...
¡A practicar!
https://github.com/janogonzalez
        /junit-lessons
Lección 0
     (cl.continuum.junit.lessons.Lesson0)
●   Creando un test con la anotación @Test
●   assertEquals(expected, actual)
Lección 1
       (cl.continuum.junit.lessons.Lesson1)
●   assertEquals(expected, actual)
●   assertArrayEquals(expecteds, actuals)
●   assertTrue(condition)
●   assertFalse(condition)
●   assertNull(object)
●   assertNotNull(object)
●   assertSame(expected, actual)
●   assertNotSame(expected, actual)
Lección 2
     (cl.continuum.junit.lessons.Lesson2)
●   @Before, @After, @BeforeClass,
    @AfterClass
Lección 3
     (cl.continuum.junit.lessons.Lesson3)
●   assertThat(actual, matcher)
Ahora un poco de teoría
Unit Testing
●   Tip para quedar como experto en testing: SUT
    es System Under Test, es decir el sistema que
    estamos probando.
●   En un test unitario el SUT es la clase en forma
    aislada.
●   Los tests unitarios prueban los métodos
    públicos de una clase.
¿Unit? Testing
●   Si al probar la clase esta hace uso de sus
    dependencias entonces estamos haciendo un
    test de integración → Yo le digo test de
    componente.
●   Para tener un test “verdaderamente” unitario
    las dependencias de la clase deben ser mocks
    → Próxima semana.
●   OJO: ¡Los tests de integración también son
    buenos!
Qué probar
●   Caso correcto
●   Caso erróneo
●   Casos de borde
●   Lanzamiento de excepciones
Los peores tests posibles
●   Uno que depende del orden de ejecución
●   Uno que no es repetible


    Un gatito muerte cada vez que alguien crea o
              ejecuta uno de esos tests
Un buen test
●   Independiente
●   Repetible
●   Automatizado
Buen diseño por default
●   Cuando hacemos unit testing...
    ●   Nuestras clases tienden a la alta cohesión y al bajo
        acoplamiento → En forma automágica :)
    ●   Nuestros métodos tienden a hacer una cosa y bien.
●   Por lo general el código de buena calidad es
    fácil de probar.
¡A practicar nuevamente!
Lección 4
●   Hello TDD!
Otro poco de teoría
El ciclo de desarrollo
●   Hasta tener la funcionalidad lista
    ●   Crear test que falla
    ●   Implementar método
    ●   Pasar el test
●   Cuando la funcionalidad ya está lista
    ●   Correr todos los tests
    ●   Subir a control de versiones
Feedback,
Feedback,
Feedback!
¿Por qué usar TDD?
●   Me obliga a hacerme preguntas sobre los
    requerimientos
●   Me obliga en forma inconsciente a utilizar las
    mejores prácticas de desarrollo
●   Cuando hacemos los tests al final, estamos
    mentalmente predispuestos a probar sólo lo
    que va a funcionar
Mitos
●   TDD es la única forma de hacer software de
    calidad
●   Es muy difícil el cambio de paradigma
●   Es muy fácil el cambio de paradigma
Ojo, oreja, pestaña y ceja:
La agilidad es un medio, no un fin
     (el fin es crear software de calidad)

Más contenido relacionado

La actualidad más candente

Como escribir buenos tests al hacer TDD
Como escribir buenos tests al hacer TDDComo escribir buenos tests al hacer TDD
Como escribir buenos tests al hacer TDDHernan Wilkinson
 
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
 
Introducción a JUnit 4
Introducción a JUnit 4Introducción a JUnit 4
Introducción a JUnit 4Juanma Gómez
 
Desarrollo Guiado Por Pruebas
Desarrollo Guiado Por PruebasDesarrollo Guiado Por Pruebas
Desarrollo Guiado Por PruebasMiguel Angel
 
Junit con netbeans
Junit con netbeansJunit con netbeans
Junit con netbeansbachispasaca
 
No debuggearás - Introducción al Unit Testing y TDD
No debuggearás - Introducción al Unit Testing y TDDNo debuggearás - Introducción al Unit Testing y TDD
No debuggearás - Introducción al Unit Testing y TDDreyiyo
 
Pruebas Unitarias
Pruebas UnitariasPruebas Unitarias
Pruebas Unitariasggarber
 
Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Javier Morales
 
Conceptos básicos de Unit Test
Conceptos básicos de Unit Test Conceptos básicos de Unit Test
Conceptos básicos de Unit Test Juan Vladimir
 
ATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónPaulo Clavijo
 
Introducción a las Pruebas Software
Introducción a las Pruebas SoftwareIntroducción a las Pruebas Software
Introducción a las Pruebas SoftwareMicael Gallego
 
Ingenieria de sw Junit
Ingenieria de sw JunitIngenieria de sw Junit
Ingenieria de sw Junitpattyand89
 

La actualidad más candente (20)

Como escribir buenos tests al hacer TDD
Como escribir buenos tests al hacer TDDComo escribir buenos tests al hacer TDD
Como escribir buenos tests al hacer TDD
 
Tdd on the rocks
Tdd on the rocks Tdd on the rocks
Tdd on the rocks
 
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
 
Seminario SOLID-TDD
Seminario SOLID-TDDSeminario SOLID-TDD
Seminario SOLID-TDD
 
Introducción a JUnit 4
Introducción a JUnit 4Introducción a JUnit 4
Introducción a JUnit 4
 
Desarrollo Guiado Por Pruebas
Desarrollo Guiado Por PruebasDesarrollo Guiado Por Pruebas
Desarrollo Guiado Por Pruebas
 
Junit con netbeans
Junit con netbeansJunit con netbeans
Junit con netbeans
 
No debuggearás - Introducción al Unit Testing y TDD
No debuggearás - Introducción al Unit Testing y TDDNo debuggearás - Introducción al Unit Testing y TDD
No debuggearás - Introducción al Unit Testing y TDD
 
Test unitarios
Test unitariosTest unitarios
Test unitarios
 
Pruebas Unitarias
Pruebas UnitariasPruebas Unitarias
Pruebas Unitarias
 
Introducción a TDD
Introducción a TDDIntroducción a TDD
Introducción a TDD
 
Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01Cursotdd 141202105217-conversion-gate01
Cursotdd 141202105217-conversion-gate01
 
Presentación: xUnit y Junit
Presentación: xUnit y JunitPresentación: xUnit y Junit
Presentación: xUnit y Junit
 
Conceptos básicos de Unit Test
Conceptos básicos de Unit Test Conceptos básicos de Unit Test
Conceptos básicos de Unit Test
 
ATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de Aceptación
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
U2T4 - Pruebas del Software
U2T4 - Pruebas del SoftwareU2T4 - Pruebas del Software
U2T4 - Pruebas del Software
 
Introducción a las Pruebas Software
Introducción a las Pruebas SoftwareIntroducción a las Pruebas Software
Introducción a las Pruebas Software
 
Ingenieria de sw Junit
Ingenieria de sw JunitIngenieria de sw Junit
Ingenieria de sw Junit
 
Unit Testing en iOS
Unit Testing en iOSUnit Testing en iOS
Unit Testing en iOS
 

Similar a Unit Testing y TDD en Java - Parte 1

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
 
[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
 
"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturinowebcat
 
Pruebas Automatizadas
Pruebas AutomatizadasPruebas Automatizadas
Pruebas AutomatizadasAngel Nuñez
 
Gestión de pruebas en desarrollo software
Gestión de pruebas en desarrollo softwareGestión de pruebas en desarrollo software
Gestión de pruebas en desarrollo softwareLaura M. Castro
 
Meetup TestingUY 2016 - Experimentando y Explorando
Meetup TestingUY 2016 - Experimentando y ExplorandoMeetup TestingUY 2016 - Experimentando y Explorando
Meetup TestingUY 2016 - Experimentando y ExplorandoTestingUy
 
Unit Testing with Mock Objects
Unit Testing with Mock ObjectsUnit Testing with Mock Objects
Unit Testing with Mock ObjectsAngel Nuñez
 
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
 
Ponele el TURBO al Dev Team de tu Startup
Ponele el TURBO al Dev Team de tu StartupPonele el TURBO al Dev Team de tu Startup
Ponele el TURBO al Dev Team de tu StartupMartin Siniawski
 
Taller de Simpletest - Drupal Day Valencia 2012
Taller de Simpletest - Drupal Day Valencia 2012Taller de Simpletest - Drupal Day Valencia 2012
Taller de Simpletest - Drupal Day Valencia 2012Juampy NR
 
Artalde Tdd intro
Artalde Tdd introArtalde Tdd intro
Artalde Tdd introfperezplain
 
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)Joan Queralt
 
Testing en proyectos Grails del día a día. Greach 2013
Testing en proyectos Grails del día a día. Greach 2013Testing en proyectos Grails del día a día. Greach 2013
Testing en proyectos Grails del día a día. Greach 2013Dani Latorre
 
Introducción al testing unitario
Introducción al testing unitarioIntroducción al testing unitario
Introducción al testing unitarioJuanma Gómez
 
Introducción al testing unitario
Introducción al testing unitarioIntroducción al testing unitario
Introducción al testing unitarioJuanma Gómez
 
Taller PyConEs 2016: Introducción a TDD
Taller PyConEs 2016: Introducción a TDDTaller PyConEs 2016: Introducción a TDD
Taller PyConEs 2016: Introducción a TDDAlea Soluciones, S.L.
 

Similar a Unit Testing y TDD en Java - Parte 1 (20)

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
 
[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
 
"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino"Demystifying development techniques" por @eturino
"Demystifying development techniques" por @eturino
 
Pruebas Automatizadas
Pruebas AutomatizadasPruebas Automatizadas
Pruebas Automatizadas
 
Gestión de pruebas en desarrollo software
Gestión de pruebas en desarrollo softwareGestión de pruebas en desarrollo software
Gestión de pruebas en desarrollo software
 
Tdd - Primeros Pasos
Tdd - Primeros PasosTdd - Primeros Pasos
Tdd - Primeros Pasos
 
Meetup TestingUY 2016 - Experimentando y Explorando
Meetup TestingUY 2016 - Experimentando y ExplorandoMeetup TestingUY 2016 - Experimentando y Explorando
Meetup TestingUY 2016 - Experimentando y Explorando
 
Unit Testing with Mock Objects
Unit Testing with Mock ObjectsUnit Testing with Mock Objects
Unit Testing with Mock Objects
 
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
 
Ponele el TURBO al Dev Team de tu Startup
Ponele el TURBO al Dev Team de tu StartupPonele el TURBO al Dev Team de tu Startup
Ponele el TURBO al Dev Team de tu Startup
 
Taller de Simpletest - Drupal Day Valencia 2012
Taller de Simpletest - Drupal Day Valencia 2012Taller de Simpletest - Drupal Day Valencia 2012
Taller de Simpletest - Drupal Day Valencia 2012
 
Doble o nada
Doble o nadaDoble o nada
Doble o nada
 
Artalde Tdd intro
Artalde Tdd introArtalde Tdd intro
Artalde Tdd intro
 
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)
Mootes11: Presentacion Tarea con revisión por compañeros (Peer Review Task)
 
Si no testeo no me lo creo
Si no testeo no me lo creoSi no testeo no me lo creo
Si no testeo no me lo creo
 
Testing en proyectos Grails del día a día. Greach 2013
Testing en proyectos Grails del día a día. Greach 2013Testing en proyectos Grails del día a día. Greach 2013
Testing en proyectos Grails del día a día. Greach 2013
 
Testing etapa olvidada
Testing etapa olvidadaTesting etapa olvidada
Testing etapa olvidada
 
Introducción al testing unitario
Introducción al testing unitarioIntroducción al testing unitario
Introducción al testing unitario
 
Introducción al testing unitario
Introducción al testing unitarioIntroducción al testing unitario
Introducción al testing unitario
 
Taller PyConEs 2016: Introducción a TDD
Taller PyConEs 2016: Introducción a TDDTaller PyConEs 2016: Introducción a TDD
Taller PyConEs 2016: Introducción a TDD
 

Más de Jano González

JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011
JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011
JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011Jano González
 
JRuby: Ruby en un mundo enterprise
JRuby: Ruby en un mundo enterpriseJRuby: Ruby en un mundo enterprise
JRuby: Ruby en un mundo enterpriseJano González
 
Programación Políglota en la JVM
Programación Políglota en la JVMProgramación Políglota en la JVM
Programación Políglota en la JVMJano González
 
JRuby ¿Lo mejor de dos mundos?
JRuby ¿Lo mejor de dos mundos?JRuby ¿Lo mejor de dos mundos?
JRuby ¿Lo mejor de dos mundos?Jano González
 
Un emulador de Game Boy escrito en Ruby (parte 1)
Un emulador de Game Boy escrito en Ruby (parte 1)Un emulador de Game Boy escrito en Ruby (parte 1)
Un emulador de Game Boy escrito en Ruby (parte 1)Jano González
 
Curso de Spring: Transacciones
Curso de Spring: TransaccionesCurso de Spring: Transacciones
Curso de Spring: TransaccionesJano González
 
Análisis y Diseño OO 2
Análisis y Diseño OO 2Análisis y Diseño OO 2
Análisis y Diseño OO 2Jano González
 
Análisis y Diseño OO 1
Análisis y Diseño OO 1Análisis y Diseño OO 1
Análisis y Diseño OO 1Jano González
 
Curso de Spring: Beans
Curso de Spring: BeansCurso de Spring: Beans
Curso de Spring: BeansJano González
 
Un newbie conoce a Sinatra
Un newbie conoce a SinatraUn newbie conoce a Sinatra
Un newbie conoce a SinatraJano González
 

Más de Jano González (15)

Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
Vim FTW!
Vim FTW!Vim FTW!
Vim FTW!
 
Ruby
RubyRuby
Ruby
 
JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011
JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011
JRuby: Ruby en un mundo enterprise RubyConf Uruguay 2011
 
JRuby: Ruby en un mundo enterprise
JRuby: Ruby en un mundo enterpriseJRuby: Ruby en un mundo enterprise
JRuby: Ruby en un mundo enterprise
 
Programación Políglota en la JVM
Programación Políglota en la JVMProgramación Políglota en la JVM
Programación Políglota en la JVM
 
A Little RSpec
A Little RSpecA Little RSpec
A Little RSpec
 
JRuby ¿Lo mejor de dos mundos?
JRuby ¿Lo mejor de dos mundos?JRuby ¿Lo mejor de dos mundos?
JRuby ¿Lo mejor de dos mundos?
 
Un emulador de Game Boy escrito en Ruby (parte 1)
Un emulador de Game Boy escrito en Ruby (parte 1)Un emulador de Game Boy escrito en Ruby (parte 1)
Un emulador de Game Boy escrito en Ruby (parte 1)
 
Curso de Spring: Transacciones
Curso de Spring: TransaccionesCurso de Spring: Transacciones
Curso de Spring: Transacciones
 
Análisis y Diseño OO 2
Análisis y Diseño OO 2Análisis y Diseño OO 2
Análisis y Diseño OO 2
 
Análisis y Diseño OO 1
Análisis y Diseño OO 1Análisis y Diseño OO 1
Análisis y Diseño OO 1
 
Programación Java
Programación JavaProgramación Java
Programación Java
 
Curso de Spring: Beans
Curso de Spring: BeansCurso de Spring: Beans
Curso de Spring: Beans
 
Un newbie conoce a Sinatra
Un newbie conoce a SinatraUn newbie conoce a Sinatra
Un newbie conoce a Sinatra
 

Último

GonzalezGonzalez_Karina_M1S3AI6... .pptx
GonzalezGonzalez_Karina_M1S3AI6... .pptxGonzalezGonzalez_Karina_M1S3AI6... .pptx
GonzalezGonzalez_Karina_M1S3AI6... .pptx241523733
 
Trabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfTrabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfedepmariaperez
 
CommitConf 2024 - Spring Boot <3 Testcontainers
CommitConf 2024 - Spring Boot <3 TestcontainersCommitConf 2024 - Spring Boot <3 Testcontainers
CommitConf 2024 - Spring Boot <3 TestcontainersIván López Martín
 
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptLUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptchaverriemily794
 
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6    CREAR UN RECURSO MULTIMEDIAActividad integradora 6    CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA241531640
 
Presentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia ArtificialPresentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia Artificialcynserafini89
 
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxModelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxtjcesar1
 
tarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzztarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzzAlexandergo5
 
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptx
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptxEl_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptx
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptxAlexander López
 
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxCrear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxNombre Apellidos
 
TALLER DE ANALISIS SOLUCION PART 2 (1)-1.docx
TALLER DE ANALISIS SOLUCION  PART 2 (1)-1.docxTALLER DE ANALISIS SOLUCION  PART 2 (1)-1.docx
TALLER DE ANALISIS SOLUCION PART 2 (1)-1.docxobandopaula444
 
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúRed Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúCEFERINO DELGADO FLORES
 
Documentacion Electrónica en Actos Juridicos
Documentacion Electrónica en Actos JuridicosDocumentacion Electrónica en Actos Juridicos
Documentacion Electrónica en Actos JuridicosAlbanyMartinez7
 
Guía de Registro slideshare paso a paso 1
Guía de Registro slideshare paso a paso 1Guía de Registro slideshare paso a paso 1
Guía de Registro slideshare paso a paso 1ivanapaterninar
 
FloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptxFloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptx241522327
 
Tecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxTecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxGESTECPERUSAC
 
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxLAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxAlexander López
 
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOAREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOnarvaezisabella21
 
certificado de oracle academy cetrificado.pdf
certificado de oracle academy cetrificado.pdfcertificado de oracle academy cetrificado.pdf
certificado de oracle academy cetrificado.pdfFernandoOblitasVivan
 
tics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxtics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxazmysanros90
 

Último (20)

GonzalezGonzalez_Karina_M1S3AI6... .pptx
GonzalezGonzalez_Karina_M1S3AI6... .pptxGonzalezGonzalez_Karina_M1S3AI6... .pptx
GonzalezGonzalez_Karina_M1S3AI6... .pptx
 
Trabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfTrabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdf
 
CommitConf 2024 - Spring Boot <3 Testcontainers
CommitConf 2024 - Spring Boot <3 TestcontainersCommitConf 2024 - Spring Boot <3 Testcontainers
CommitConf 2024 - Spring Boot <3 Testcontainers
 
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptLUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
 
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6    CREAR UN RECURSO MULTIMEDIAActividad integradora 6    CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
 
Presentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia ArtificialPresentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia Artificial
 
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxModelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
 
tarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzztarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzz
 
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptx
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptxEl_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptx
El_Blog_como_herramienta_de_publicacion_y_consulta_de_investigacion.pptx
 
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxCrear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
 
TALLER DE ANALISIS SOLUCION PART 2 (1)-1.docx
TALLER DE ANALISIS SOLUCION  PART 2 (1)-1.docxTALLER DE ANALISIS SOLUCION  PART 2 (1)-1.docx
TALLER DE ANALISIS SOLUCION PART 2 (1)-1.docx
 
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúRed Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
 
Documentacion Electrónica en Actos Juridicos
Documentacion Electrónica en Actos JuridicosDocumentacion Electrónica en Actos Juridicos
Documentacion Electrónica en Actos Juridicos
 
Guía de Registro slideshare paso a paso 1
Guía de Registro slideshare paso a paso 1Guía de Registro slideshare paso a paso 1
Guía de Registro slideshare paso a paso 1
 
FloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptxFloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptx
 
Tecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxTecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptx
 
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxLAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
 
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOAREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
 
certificado de oracle academy cetrificado.pdf
certificado de oracle academy cetrificado.pdfcertificado de oracle academy cetrificado.pdf
certificado de oracle academy cetrificado.pdf
 
tics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxtics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptx
 

Unit Testing y TDD en Java - Parte 1

  • 1. Taller de Unit Testing y TDD en Java Parte 1 Jano González Desarrollador
  • 2. Parte 1 ● Iremos desde la práctica hacia la teoría: ● Uso de JUnit 4 ● Matchers básicos ● Ejemplo simple (demasiado?) de TDD
  • 3. Parte 2 ● Próximo L&B ● Iremos desde la práctica hacia la teoría: ● Otros matchers ● Mock objects ● Ejemplo de TDD ● Cómo hacer buenos tests
  • 4. Parte N ● Si les interesa podemos hacer más talleres...
  • 7. Lección 0 (cl.continuum.junit.lessons.Lesson0) ● Creando un test con la anotación @Test ● assertEquals(expected, actual)
  • 8. Lección 1 (cl.continuum.junit.lessons.Lesson1) ● assertEquals(expected, actual) ● assertArrayEquals(expecteds, actuals) ● assertTrue(condition) ● assertFalse(condition) ● assertNull(object) ● assertNotNull(object) ● assertSame(expected, actual) ● assertNotSame(expected, actual)
  • 9. Lección 2 (cl.continuum.junit.lessons.Lesson2) ● @Before, @After, @BeforeClass, @AfterClass
  • 10. Lección 3 (cl.continuum.junit.lessons.Lesson3) ● assertThat(actual, matcher)
  • 11. Ahora un poco de teoría
  • 12. Unit Testing ● Tip para quedar como experto en testing: SUT es System Under Test, es decir el sistema que estamos probando. ● En un test unitario el SUT es la clase en forma aislada. ● Los tests unitarios prueban los métodos públicos de una clase.
  • 13. ¿Unit? Testing ● Si al probar la clase esta hace uso de sus dependencias entonces estamos haciendo un test de integración → Yo le digo test de componente. ● Para tener un test “verdaderamente” unitario las dependencias de la clase deben ser mocks → Próxima semana. ● OJO: ¡Los tests de integración también son buenos!
  • 14. Qué probar ● Caso correcto ● Caso erróneo ● Casos de borde ● Lanzamiento de excepciones
  • 15. Los peores tests posibles ● Uno que depende del orden de ejecución ● Uno que no es repetible Un gatito muerte cada vez que alguien crea o ejecuta uno de esos tests
  • 16. Un buen test ● Independiente ● Repetible ● Automatizado
  • 17. Buen diseño por default ● Cuando hacemos unit testing... ● Nuestras clases tienden a la alta cohesión y al bajo acoplamiento → En forma automágica :) ● Nuestros métodos tienden a hacer una cosa y bien. ● Por lo general el código de buena calidad es fácil de probar.
  • 19. Lección 4 ● Hello TDD!
  • 20. Otro poco de teoría
  • 21. El ciclo de desarrollo ● Hasta tener la funcionalidad lista ● Crear test que falla ● Implementar método ● Pasar el test ● Cuando la funcionalidad ya está lista ● Correr todos los tests ● Subir a control de versiones
  • 23. ¿Por qué usar TDD? ● Me obliga a hacerme preguntas sobre los requerimientos ● Me obliga en forma inconsciente a utilizar las mejores prácticas de desarrollo ● Cuando hacemos los tests al final, estamos mentalmente predispuestos a probar sólo lo que va a funcionar
  • 24. Mitos ● TDD es la única forma de hacer software de calidad ● Es muy difícil el cambio de paradigma ● Es muy fácil el cambio de paradigma
  • 25. Ojo, oreja, pestaña y ceja: La agilidad es un medio, no un fin (el fin es crear software de calidad)