Slide 1

Slide 1 text

Behat

Slide 2

Slide 2 text

Testing

Slide 3

Slide 3 text

MAking sure shit works

Slide 4

Slide 4 text

MAking sure shit works and doesn't break

Slide 5

Slide 5 text

Development

Slide 6

Slide 6 text

Development Driven Test

Slide 7

Slide 7 text

Unit Testing

Slide 8

Slide 8 text

Unit Testing

Slide 9

Slide 9 text

Development Driven Test

Slide 10

Slide 10 text

Development Driven Behavior

Slide 11

Slide 11 text

Behat Testing with

Slide 12

Slide 12 text

@mloberg

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Behat Intro to

Slide 15

Slide 15 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 16

Slide 16 text

Read Easy To

Slide 17

Slide 17 text

Understand Easy To

Slide 18

Slide 18 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 19

Slide 19 text

WhY?

Slide 20

Slide 20 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 21

Slide 21 text

Who?

Slide 22

Slide 22 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 23

Slide 23 text

How?

Slide 24

Slide 24 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 25

Slide 25 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 26

Slide 26 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 27

Slide 27 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 28

Slide 28 text

Feature: Login In order to view my upcoming concerts As a registered user I need to be able to login Scenario: Successful login with correct credentials Given there is a user "mloberg" with password "testing" When I view the login page And I fill in "username" with "mloberg" And I fill in "password" with "testing" And I press "login" Then I should see "Hello, mloberg" Scenario: Can't login with invalid credentials ...

Slide 29

Slide 29 text

Setup

Slide 30

Slide 30 text

composer require --dev behat/behat ./vendor/bin/behat --init

Slide 31

Slide 31 text

Demo

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Contexts Definitions &

Slide 34

Slide 34 text

/** * @When I do something with :argument */ public function iDoSomethingWith($argument) { // do something with $argument }

Slide 35

Slide 35 text

/** * @When I do something with :argument */ public function iDoSomethingWith($argument) { // do something with $argument }

Slide 36

Slide 36 text

/** * @When I do something with :argument */ public function iDoSomethingWith($argument) { // do something with $argument }

Slide 37

Slide 37 text

/** * @When /^I do something with "([^"]*)"$/ */ public function iDoSomethingWith($argument) { // do something with $argument }

Slide 38

Slide 38 text

/** * @Then This thing should happen */ public function thisThingShouldHappen() { // Test that the thing happened }

Slide 39

Slide 39 text

/** * @Given The user :username has :password */ public function userExists($username, $password) { // Create a user with a password }

Slide 40

Slide 40 text

use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\TableNode; class FeatureContext implements SnippetAcceptingContext { /** * Initializes context. */ public function __construct() { } // Definitions go here }

Slide 41

Slide 41 text

API Demo

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Interaction Browser

Slide 44

Slide 44 text

Mink

Slide 45

Slide 45 text

App Demo

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Questions?

Slide 48

Slide 48 text

Behat Testing with