bdd & cucumber
DESCRIPTION
BDD y CucumberTRANSCRIPT
-
BDD & Dos amigos inseparables
@EnriqueSanchezB www.enrique-sanchez.me
-
Quin es este pesao? Technical Team Leader y Responsable Tcnico del rea de
Testing en !!! Ms de 3 aos de experiencia en testing en empresas
como !!
! Evangelista BDD y Agile
-
Actualmente echo una mano montando entornos y diseando la estrategia de testing automtico en
Quin es este pesao?
-
De qu va a ir esta charla?
Qu es eso de BDD, TDD, ATDD y todas esas siglas raras?
Qu tiene de especial el BDD? Es otra moda ms?
Cucumber? En serio?
-
Un poco de historia
Debugging oriented
Demonstration oriented
Destruction oriented
Evaluation oriented
Prevention oriented
1957 1978 1982 1988
Fuente: Gelperin, D.; B. Hetzel. "The Growth of Software Testing"
-
ESO NO ES AGILE!!!
-
Waterfall
-
Coste de un cambio
-
Agile ManifestoThe style here is to write a few lines of code, then a test that should run, or even better, to write a test that won't run, then write the code that will make it run. [] Now, instead of just coding on, we want to get immediate feedback and practice "code a little, test a little, code a little, test a little."
-
Agile ManifestoThe style here is to write a few lines of code, then a test that should run, or even better, to write a test that won't run, then write the code that will make it run. [] Now, instead of just coding on, we want to get immediate feedback and practice "code a little, test a little, code a little, test a little."
TDD
-
Specication By DefectSpecification By Example isn't the way most of us have been brought up to think of specifications. Specifications are supposed to be general, to cover all cases. Examples only highlight a few points, you have to infer the generalizations yourself. This does mean that Specification By Example can't be the only requirements technique you use, but it doesn't mean that it can't take a leading role.
-
Specication By DefectSpecification By Example isn't the way most of us have been brought up to think of specifications. Specifications are supposed to be general, to cover all cases. Examples only highlight a few points, you have to infer the generalizations yourself. This does mean that Specification By Example can't be the only requirements technique you use, but it doesn't mean that it can't take a leading role.
ATDD
-
Behaviour Drive-Development
Behaviour is a more useful word than test
-
Behaviour Drive-Development
Behaviour is a more useful word than testBDD
-
BDD se centra en el comportamiento mientras que TDD se centra en la implementacin
ATDD se centra en capturar requisitos en test de aceptacin y los usa para conducir el desarrollo
ATDD est centrado en los requisitos desde el punto de vista del desarrollador, BDD est enfocado en la captura de requisitos desde el cliente
-
Qu es BDD? Mtodo de diseo y codificacin que integra
pruebas.
Aceptacin Unitarias
Orienta a un desarrollo Outside -> In
Define el uso de un DSL para pruebas
Un subconjunto del lenguaje natural > Gherkin
-
Gherkin
Business Readable
Describe el comportamiento del software sin importar el desarrollo
Documentacin
-
Gherkin: Sintaxis
https://github.com/cucumber/cucumber/wiki/Gherkin
-
Cucumber Framework BDD
Escrito en Ruby pero disponible para Java (Cucumber-JVM), Python (Lettuce), Javascript (cucumber-js)
http://cukes.info/
-
Cucumber: Lo quiero!!1. Instala Ruby* !\curl -sSL https://get.rvm.io | bash -s stable
!
2. Instala Cucumber !sudo gem install cucumber
* Instala: ltima versin de Ruby + RVM (Ruby version manager) + RubyGems
-
Cucumber: Cmo funciona?
Es una herramienta de lnea de comandos
Lee los ficheros .features del directorio indicado
Por cada uno de los scenarios ejecuta los steps
-
Cucumber: Cmo funciona?
-
Quiero ver un ejemplo que no me gusta la magia!!!!
-
El entorno
Configurar todo esto es un engorro
Y NOSOTROS NO ESTAMOS AQU PARA ESTO!
-
El entorno Usemos Vagrant (http://www.vagrantup.com/)
Bjate la ltima versin de VirtualBox (https://www.virtualbox.org/)
Instala Vagrant (http://www.vagrantup.com/downloads.html)
Instala Git (http://git-scm.com/)
Clona este proyecto
git clone https://github.com/enriquesanchezb/vagrant-cucumber-watir.git
Arranca vagrant
vagrant up
vagrant ssh
-
El entorno Y ya lo tienes montado madafaca !!!
-
Cucumber: Primeros Pasos Crea un directorio: kit-cucumber
Crea un subdirectorio features
Crea un archivo: features/first_steps.features
En la consola sitate en el directorio y escribe: cucumber
-
Cucumber: Primeros Pasos Crear un test es simple: abre un editor de texto y escribe
Feature: Division In order to avoid silly mistakes Cashiers must be able to calculate a fraction ! Scenario: Regular numbers Given I have entered 3 into the calculator And I have entered 2 into the calculator When I press divide Then the result should be 1.5 on the screen
Ahora ejecuta:> cucumber features/first_steps.features
-
Cucumber: Primeros Pasos Crear un test es simple: abre un editor de texto y escribe
Feature: Division In order to avoid silly mistakes Cashiers must be able to calculate a fraction ! Scenario: Regular numbers Given I have entered 3 into the calculator And I have entered 2 into the calculator When I press divide Then the result should be 1.5 on the screen
Ahora ejecuta:> cucumber features/first_steps.features
wow so easy
much minimalist
so hipster
-
Cucumber: Primeros Pasos
-
Cucumber: Primeros Pasos
Crea un directorio dentro del directorio features llamado step_definitions
Copia la salida obtenida de la ejecucin del test y cpiala a un nuevo fichero llamado features/step_definitions/first.rb
Ejecuta el test de nuevo
-
Cucumber: Primeros Pasos
-
Arreglemos el test editando el fichero first.rb y creando una clase Calculator que permita realizar operaciones.
Ejecutemos de nuevo
Cucumber: Primeros Pasos
-
ESO NO VALE PARA NADA!!!
QUIERO ALGO DE VERDAD
-
Browsing Tests
Probemos una web real
!
Usemos
-
Pero esto se usa de verdad?
-
Veamos indeed
-
y careers 2.0
-
Entonces
El testing no es slo probar cosas a mano si no que debe de formar parte de la cultura de la organizacin
BDD y Cucumber son muy demandados por la industria ya que permite introducir testing desde el principio del desarrollo
-
Entonces
Aprende BDD que lo vas a necesitar
-
Por dnde empiezo?
Cucumber Website: http://cukes.info/
Asiste a alguna de las charlas gratuitas que da MADQA http://www.meetup.com/MADQA-Grupo-Meetup-de-QA-y-TESTING-de-SOFTWARE-en-Madrid/
Lee y practica: https://github.com/cucumber/cucumber/wiki/tutorials-and-related-blog-posts
-
Por dnde empiezo?
Busco un becario para montar un entorno de Integracin Continua en el FRAV
! En Medianet estamos contratando!
-
Rompe algo y no tengas miedo a
equivocarte
Por dnde empiezo?
-
!@EnriqueSanchezB