4. IN YOUR ZONE
Behavior Driven Development
4
What is BDD…
Stories & Scenarios
As a [X]
I want [Y]
So that [Z]
5. IN YOUR ZONE
ATDD vs TDD
5
•Tests are focused on business rule or
behavior.
•Written by the team.
•For the whole team
•They are run frequently by the team.
•New tests fail until story is done. Older
tests should all pass.
•Tests are focused on technical aspects of
the application.
•Written by developers
•...for developers
•They are run frequently by the team.
•All tests pass 100% before commit and
integration.
ATDD TDD
In both cases tests are written before the solution code.
They look similar but are not replacements for each other.
6. IN YOUR ZONE
BDD Stories & Scenarios
6
Story
• Title: Customer pays bills
through internet banking
• As a customer,
• I want to pay bills through
internet banking,
• So that I don’t have to make a
trip to each supplier.
Scenario 1
• Scenario 1: There is enough
credit
• Given the account is in credit
• And the user is properly
authenticated
• When the customer attempts to
make a payment to a supplier
• And he inputs the correct bill
details
• Then ensure the transaction is
recorded
• And ensure the amount of
money is debited
7. IN YOUR ZONE
Setting up the project
7
JDK
• At least 5
IDE
• Eclipse
Maven
• Sonatype repository
• mvn archetype:generate
8. IN YOUR ZONE
Writing stuff
8
Features •@Feature
JBehave
•Stories
•Scenarios
Mid level
•Junit tests
•Mapped to Jbehave lines
Low level
•PageObject
•Every page has a corresponding PageObject class.
•Get & set for the page
•No assertions
•User (steps) class
•Emulates the user.
•Performs assertions
9. IN YOUR ZONE
Running tests - Eclipse
9
• Extend ThucydidesJUnitStories
• Refine with
• findStoriesIn
• findStoriesCalled
• Run/Debug
10. IN YOUR ZONE
Running tests - Maven
10
• 1. If the project is clean, first run
• mvn test thucydides:archetype
• Any other normal test run
• mvn integration-test thucydides:archetype
• Only this one will run the tests and generate a report for that
18. IN YOUR ZONE
Quiz Time
18
•Get the title of all the posts on page
•Assert all titles contain keyword
•Assert titles not containing keyword are not displayed
Thucydides is a tool that lets you use WebDriver-based unit or BDD tests to write more flexible and more reusable WebDriver-based tests, and also to generate documentation about your acceptance tests, including a narrative description of test, along with the corresponding screen shots, and also high-level summaries and aggregations of the test results.Jbehave & Easybsunt 2 formate de scriere a story-urilor agile, cel din urmă fiind bazat pe groovy.Am lucrat cuacest framework pentru câtevasăpt și am căutat inițial funcționalități pentru testarea cross-browser-testing.
BDD a evoluat din practicile agile și a fost conceput pentru a le face mai accesibile și eficiente pentru echipele de dezvoltare.Principalul beneficiu este capacitatea de a scrie testele într-un limbaj accesibil tuturor membrilor echipei.X reprezintă o persoană, Y reprezintă o funcționalitate iar Z reprezintă un beneficiu obținut prin implementarea funcționalității. Această abordare are capacitatea de a defini valoarea unei funcționalități încă înainte de a fi implementată. Dacă nu este astfel definită atunci există riscul de a implementa o funcționalitate de tipul „pentru-că-așa-vrea-clientul”. Aici este momentul în care unele cerințe „mistice” sunt filtrate corespunzător.Momentan există 2 abordări care sunt o „implementare” a BDD: ATDD & TDD.
Ca un studiu de cazam avea un story pentru achitarea facturilor prin internet banking.Iar un scenariu `happy flow` ar fi…
Before attempting to create a new project, you need to update settings.xml and include the Sonatype OSS Maven repository (http://oss.sonatype.org/). Releases can be obtained from the release repository (https://oss.sonatype.org/content/repositories/releases/). Snapshot releases are available on the Sonatype OSS Snapshot repository (https://oss.sonatype.org/content/repositories/snapshot/).
Cum este structurat un proiect:FeaturesAjută în rapoarte prin asocierea testelor cu funcționalitățiledeSunt doar clase goale care reprezintă funcționalitățile aplicațieiJBehaveStoriesScenariosKeyword-urile sunt bazate pe conceptul BDD (Given, When, Then, And etc.)MidlevelJunittests conectate la scenarii folosind anotații (@Given, @When, @Then etc.)Se pot folosi expresii regulate, tabele, data-driven-testsLowlevelPageObjectFicare pagină are User (steps) class
Running tests with maven has the advantage of generating reports.
We will be testing the wordpress application for some basic functionalities.
Motivul pentru care acesta este pas nu pare să fie integrabil cu JBehave, ci doar cu testele story-urile scrise în easyB sau JUnit.