Download - Behat & Automated Testing (Lightning Talk)
![Page 2: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/2.jpg)
The dream “Let the computer do the repetitive, mind numbing work”
![Page 3: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/3.jpg)
Outline
1. What?!
2. How?!
3. Why?
![Page 4: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/4.jpg)
What is Behat?
PHP!
BDD!
Gerkins!
Selenium
![Page 5: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/5.jpg)
What is Behat?
Converts English to Automated browser tests
![Page 6: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/6.jpg)
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”
![Page 7: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/7.jpg)
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
![Page 8: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/8.jpg)
Demo
![Page 9: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/9.jpg)
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
![Page 10: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/10.jpg)
Why would you use it?
Automated!
Proof!
Regressions
![Page 11: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/11.jpg)
Why else?Cross-browser/OS testing!!
!
!
!
!
!
![Page 12: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/12.jpg)
Why else?
Anyone can write tests!
! With some caveats
![Page 13: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/13.jpg)
![Page 14: Behat & Automated Testing (Lightning Talk)](https://reader034.vdocument.in/reader034/viewer/2022051611/54b7b9814a7959c9688b4787/html5/thumbnails/14.jpg)
Related links
❖ Moodle’s Acceptance testing docs http://docs.moodle.org/dev/Acceptance_testing!
❖ KNP Labs BDD/Behat training http://knplabs.com/training/behat