Functional Tests with Geb

40
PTD Pucela Testing Days Jorge Jiménez @semurat

description

Slides from my talk in Pucela Testing Days 2013 about functional testing with Geb

Transcript of Functional Tests with Geb

Page 1: Functional Tests with Geb

PTD Pucela Testing Days

Jorge Jiménez @semurat

Page 2: Functional Tests with Geb

GEB Tests Funcionales

Page 3: Functional Tests with Geb

<me>Miembro de BeCode

!Desarrollador

Convencido de Agile Freak Geek

¿Emprendedor? ....

</me>

Page 4: Functional Tests with Geb

¿Tests Funcionales?

Page 5: Functional Tests with Geb

¿Tests Funcionales?

¿Tests de Aceptación?

Page 6: Functional Tests with Geb

¿Tests Funcionales?

¿Tests de Aceptación?

¿Tests de Usuario?

Page 7: Functional Tests with Geb

¿Cómo pruebas tus aplicaciones web?

Page 8: Functional Tests with Geb

¿Cómo pruebas tus aplicaciones web?

Page 9: Functional Tests with Geb

¿Cómo pruebas tus aplicaciones web?

!

Son lentos Difíciles de automatizar Débiles

Page 10: Functional Tests with Geb

¿Cómo pruebas tus aplicaciones web?

!

Validan que la aplicación funciona Iteraciones más rápidas Ahorran dinero

Page 11: Functional Tests with Geb

Soluciones

Grabando acciones ! Selenium IDE

Scripting !!

Model Driven ! WebDriver con Page Objects

Page 12: Functional Tests with Geb

Soluciones Scripting !!

Model Driven ! WebDriver con Page Objects

Lenguaje Natural ! Cucumber

Page 13: Functional Tests with Geb

GEB

Page 14: Functional Tests with Geb

Selenium WebDriver !

Estilo jQuery de selección !

Modelado con Page Object !

Expresividad de Groovy !

Buena documentación !

Integrado con otros frameworks

Page 15: Functional Tests with Geb

GEB

Page 16: Functional Tests with Geb

DEMO 1

Page 17: Functional Tests with Geb

NAvigator API

Page 18: Functional Tests with Geb

El método $()Devuelve un objeto Navigator

Formato:

Selectores

Matching

Chaining

Form

Page 19: Functional Tests with Geb

Ejemplos

Page 20: Functional Tests with Geb

Contenido relativo

Page 21: Functional Tests with Geb

JavaScript & Ajax

Aplicaciones web modernas son asincronas:

Ajax Efectos Aplicaciones Single Page

Page 22: Functional Tests with Geb

JavaScript & Ajax

Polling

Page 23: Functional Tests with Geb

JavaScript & Ajax

Acceso a JS

Page 24: Functional Tests with Geb

Páginas y MódulosPage Object Pattern

! “A page object wraps an HTML page, or fragment, with an application-specific API, allowing you to manipulate page elements without digging around in the HTML.” !

Martin Fowler 10/09/2013

Page 25: Functional Tests with Geb

Páginas y Módulos

Page 26: Functional Tests with Geb

Páginas y MódulosAbstracción que modeliza y da

estructura a nuestro código

Page 27: Functional Tests with Geb

Páginas y Módulos

Una página.... !

Encapsula la estructura El Comportamiento aparece en métodos Unidades Reusables

Page 28: Functional Tests with Geb

Páginas y MódulosPáginas en Geb

Page 29: Functional Tests with Geb

Páginas y MódulosPáginas en Geb - NAVEGACION

Page 30: Functional Tests with Geb

Páginas y MódulosPáginas en Geb - ¿Página correcta?

Page 31: Functional Tests with Geb

Páginas y MódulosPáginas en Geb - Content DSL

Page 32: Functional Tests with Geb

Páginas y MódulosMódulos: Fragmentos de content

reutilizados

Page 33: Functional Tests with Geb

Integración con Spock

Spock es un framework de testing BDD para Groovy Lenguaje de specification altamente expresivo Se ejecuta sobre un JRunner de JUnit Sigue el concepto de BDD: Given-When-Then Given: pone el sistema en un estado conocido When: describe la acción a realizar Then: observa el resultado del test

Page 34: Functional Tests with Geb

Integración con Spock

Framework Artifact Base class

Spock geb-spock geb.spock.GebSpec

JUnit4 geb-junit4 geb.junit4.GebTest

JUnit3 geb-junit3 geb.junit3.GebTest

TestNG geb-testng geb.testng.GebTest

Page 35: Functional Tests with Geb

Integración con Spock

Page 36: Functional Tests with Geb

DEMO 2

Page 37: Functional Tests with Geb

Configuración GebConfig.groovy

Page 38: Functional Tests with Geb

Configuración GebConfig.groovy

Page 39: Functional Tests with Geb

DEMO 3

Page 40: Functional Tests with Geb

Referencias!Home Page — www.gebish.org !Reference Documentation — www.gebish.org/manual/current !Source Code — github.com/geb/geb !User Mailing List — xircles.codehaus.org/projects/geb/lists !Maven Central — central.maven.org/maven2/org/codehaus/geb !Example projects from GitHub - Demo 1 & Demo 2 - https://github.com/semurat/geb-demo-cyliconvalley - Demo 3: https://github.com/semurat/movie-database https://github.com/semurat/geb-demo