behat & automated testing (lightning talk)

14
Lightning Talk Behat & Automated Testing Rex Lorenzo [email protected]

Upload: rex-lorenzo

Post on 15-Jan-2015

184 views

Category:

Software


2 download

DESCRIPTION

My lightning talk presentation about Behat & Automated testing at the Mountain Moot 2014.

TRANSCRIPT

Page 1: Behat & Automated Testing (Lightning Talk)

Lightning Talk

Behat & Automated Testing

Rex [email protected]

Page 2: Behat & Automated Testing (Lightning Talk)

The dream “Let the computer do the repetitive, mind numbing work”

Page 3: Behat & Automated Testing (Lightning Talk)

Outline

1. What?!

2. How?!

3. Why?

Page 4: Behat & Automated Testing (Lightning Talk)

What is Behat?

PHP!

BDD!

Gerkins!

Selenium

Page 5: Behat & Automated Testing (Lightning Talk)

What is Behat?

Converts English to Automated browser tests

Page 6: Behat & Automated Testing (Lightning Talk)

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)

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)

Demo

Page 9: Behat & Automated Testing (Lightning Talk)

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)

Why would you use it?

Automated!

Proof!

Regressions

Page 11: Behat & Automated Testing (Lightning Talk)

Why else?Cross-browser/OS testing!!

!

!

!

!

!

Page 12: Behat & Automated Testing (Lightning Talk)

Why else?

Anyone can write tests!

! With some caveats

Page 13: Behat & Automated Testing (Lightning Talk)
Page 14: Behat & Automated Testing (Lightning Talk)

Related links

❖ Moodle’s Acceptance testing docs http://docs.moodle.org/dev/Acceptance_testing!

❖ KNP Labs BDD/Behat training http://knplabs.com/training/behat