Download - Tests de aceptación con cucumber
![Page 1: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/1.jpg)
Tests de aceptación con
![Page 2: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/2.jpg)
Tests de aceptación
• La idea viene de eXtreme Programming (XP)
• Se llaman tests de aceptación porque expresan lo que el software tiene que hacer para que los stakeholders lo consideren “aceptable”
• Por lo tanto desarrolladores y stakeholders son los que escriben las pruebas
![Page 3: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/3.jpg)
Tests de aceptación
• Los tests unitarios nos dicen que lo que estamos desarrollando está correcto
• Los tests de aceptación nos dicen que lo que estamos desarrollando es lo correcto
![Page 4: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/4.jpg)
Tests de aceptación
• Aumenta el feedback se reducen los malentendidos
• Surge un lenguaje común que todos los relacionados con el proyecto entienden
• Al ser escritos como ejemplos estimula la imaginación de los participantes
![Page 5: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/5.jpg)
Cucumber
• Cucumber hace fácil leer y escribir tests de aceptación por cualquier miembro del equipo
• Cucumber se convierte en una herramienta que fomenta la colaboración y la comunicación
• Escribir tests de aceptación con Cucumber no son sólo tests, son especificaciones ejecutables
![Page 6: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/6.jpg)
Cucumber
• Los tests de Cucumber pueden ser escritos y leídos por los stakeholders, como en un documento de requisitos
• Los tests de Cucumber pueden ser ejecutados por una máquina y ver su nivel de cumplimiento
• La documentación se mantiene actualizada y refleja el estado del proyecto
• Gherkin es el lenguaje que usa Cucumber para escribir las especificaciones
![Page 7: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/7.jpg)
Feature: Sign upSign up should be quick and friendly.
Scenario: Successful sign upNew users should get a confirmation email and be
greeted personally by the site once signed in.
Given I have chosen to sign upWhen I sign up with valid detailsThen I should receive a confirmation emailAnd I should see a personalized greeting message
Scenario: Duplicate emailWhere someone tries to create an account for an email address that already exists.
Given I have chosen to sign upBut I enter an email address that has already
registeredThen I should be told that the email is already
registeredAnd I should be offered the option to recover my
password
![Page 8: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/8.jpg)
Cucumber
• Podemos indicar que varios escenarios compartan un mismo background
![Page 9: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/9.jpg)
Feature: Change PINAs soon as the bank issues new cards to customers, they aresupplied with a Personal Identification Number (PIN) thatis randomly generated by the system.
In order to be able to change it to something they can easilyremember, customers with new bank cards need to be able tochange their PIN using the ATM.Background:
Given I have been issued a new cardAnd I insert the card, entering the correct PINAnd I choose "Change PIN" from the menu
Scenario: Change PIN successfullyWhen I change the PIN to 9876Then the system should remember my PIN is now 9876
Scenario: Try to change PIN to the same as beforeWhen I try to change the PIN to the original PIN
numberThen I should see a warning messageAnd the system should not have changed my PIN
![Page 10: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/10.jpg)
Cucumber
• Podemos indicar los datos que se usan en un escenario en forma de tabla
Given a User "Michael Jackson" born on August 29, 1958And a User "Elvis" born on January 8, 1935And a User "John Lennon" born on October 9, 1940
Given these Users:| name | date of birth || Michael Jackson | August 29, 1958 || Elvis | January 8, 1935 || John Lennon | October 9, 1940 |
![Page 11: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/11.jpg)
Cucumber• Podemos ejecutar un mismo escenario con varios valores de
entrada y de salida
Scenario Outline: Withdraw fixed amountGiven I have <Balance> in my accountWhen I choose to withdraw the fixed amount of <Withdrawal>Then I should <Outcome>And the balance of my account should be <Remaining>Examples: Successful withdrawal
| Balance | Withdrawal | Outcome | Remaining || $500 | $50 | receive $50 cash | $450 || $500 | $100 | receive $100 cash | $400 |
Examples: Attempt to withdraw too much| Balance | Withdrawal | Outcome | Remaining
|| $100 | $200 | see an error message | $100
|| $0 | $50 | see an error message | $0
|
![Page 12: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/12.jpg)
Cucumber
• Podemos anotar los escenarios para ejecutar sólo los que nos interesen
@slow @widgets @nightlyScenario: Generate overnight report
Given I am logged inAnd there is a report "Total widget sales history"
![Page 13: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/13.jpg)
![Page 14: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/14.jpg)
Enlaces de interés
• http://cukes.info/• https://github.com/
cucumber/cucumber/wiki
• http://pragprog.com/book/hwcuc/the-cucumber-book
• http://pragprog.com/book/dhwcr/cucumber-recipes
![Page 15: Tests de aceptación con cucumber](https://reader035.vdocumento.com/reader035/viewer/2022062312/55632aafd8b42a5c7b8b4757/html5/thumbnails/15.jpg)
Contacto
• https://github.com/tmoreno/tutorialcucumber
• @tmorenobernal