Professional Documents
Culture Documents
com
pear channel-discover pear.behat.org
pear install behat/behat
Behat
Behatinen
two
2 mots
words
--config fichier.yml
--config=fichier.yml
--format=html out=report.html
Html Report
--expand
Display details
--story-syntax --lang=fr
--tags='@group1,@group2'
In French
Run tests on groups
Behat
Feature
en 2 mots
Feature: Descriptive text of what is desired
In order to realize a named business value
As an explicit system actor
I want to ...
Behat permet
automates
d'automatiser
the "acceptance
les tests testing"
d'acceptation
of the de
agile
la
mthodologie agile
methodology
"Scrum".
Scrum
Each
Les
testtests
is sont
written
rdigs
in dans
natural
une langue
naturelle
grce syntax.
la syntaxe Gherkin.
language
with
the Gherkin
Une
fonctionnalit
est dcrite
un fichier <nom-deA
feature
is described
by a dans
<my-feature.feature>
file. A
fonctionnalit.feature>.
Une
fonctionnalit
regroupe un
feature
is a set of cases,
called
"Scenarios".
ensemble de cas, appels Scnarios.
Each scenario is defined by:
Scnario
-Chaque
Context
(Given) est dfini par:
un contexteevents
(Etant (When)
donn que)
- Triggering
- des
vnements
dclencheurs
(Quand)
An expected result (Then)
- un rsultat attendu (Alors)
Behat
Use examples
en 2 mots
Scenario Outline: Some determinable business situation
Examples:
|
|
|
|
initialAmount
15
40
20
|
|
|
|
money
5
10
5
|
|
|
|
finalAmount
20
50
25
|
|
|
|
Page 1 : fonctionnalits
Page 2 : ct dev
Assertions:
I should see "content"
I go to "url"
I press "button"
I follow "link"
Forms:
I fill in "form_element" with "value"
I check "form_checkbox"
I uncheck "form_checkbox"
Session
$session = new \Behat\Mink\Session($driver);
$session->start(); // start
$session->reset(); // soft-reset:
$session->restart(); // hard-reset:
From the main context:
$session = $this->getSession();
From a sub-context:
$session = $this->getMainContext()->getSession();
isStarted()
start()
Starts session
stop()
Stop session
restart()
Restart session
reset()
Reset session
getPage()
getSelectorHandler()
visit($url)
setBasicAuth($u,$p)
setRequestHeader($n,$v)
getResponseHeaders()
setCookie($n,$v)
Sets cookie
getCookie($n)
Returns cookie
getStatusCode()
getCurrentUrl()
reload()
back()
Moves backward
forward()
Move forward
executeScript($script)
Executes javascript
evaluateScript($script)
wait($time, $condition)
Available drivers
Goutte:
https://github.com/fabpot/Goutte
Sahi:
http://sourceforge.net/projects/sahi/
Zombie:
http://zombie.labnotes.org/
Selenium (1 & 2 ):
http://seleniumhq.org/
Events:
$el->click()
$el->doubleClick()
$el->rightClick()
$el->mouseOver()
$el->focus()
$el->blur()
$el->dragTo($element)
Forms:
$el->press()
$el->check()
$el->uncheck()
$el->isChecked()
$el->selectOption($option, $multiple)
$el->attachFile($path)
$el->keypress()
$el->keyDown()
$el->keyUp()