Download - Behat & Automated Testing (Lightning Talk)
The dream “Let the computer do the repetitive, mind numbing work”
Outline
1. What?!
2. How?!
3. Why?
What is Behat?
PHP!
BDD!
Gerkins!
Selenium
What is Behat?
Converts English to Automated browser tests
How do you use it?
Scenario: Seeing a welcome message!
Given I log in as “teacher”!
When I follow “My Course”!
Then I should see “Welcome to My Course”
Hundreds of “steps”
Given I turn editing mode on!
Given I create a course with:!
| fullname | shortname | format |!
| Math 101 | math101 | topic |!
Given I import “source” course into “destination” course
Demo
How does it work?Example: When I follow “My Course”!
/** * @When /^I follow "(?P<link_string>(?:[^"]|\\")*)"$/!
*/!
public function click_link($link) {!
$linknode = $this->find_link($link);!
$linknode->click();!
}!
Regular expressions
Why would you use it?
Automated!
Proof!
Regressions
Why else?Cross-browser/OS testing!!
!
!
!
!
!
Why else?
Anyone can write tests!
! With some caveats
Related links
❖ Moodle’s Acceptance testing docs http://docs.moodle.org/dev/Acceptance_testing!
❖ KNP Labs BDD/Behat training http://knplabs.com/training/behat