BDD, Behat, Mink and other Wonderful Things

Looking for Behat v2.5 of the tutorial? See https://knpuniversity.com/screencast/behat-v25.

Behat is my absolute favorite library to use. First, it let's me think about the behavior of my features first, before I start developing. In this tutorial, we'll do that, and it'll change the way you develop. Second, Behat turns that written behavior into functional tests against your application. Does your feature behave correctly? Just run the automated robots to find out!

Along the way, we'll master Mink - the partner library to Behat - and solve all sorts of common problems, like:

  • Running scenarios in a real browser
  • Properly waiting or JavaScript events
  • Leveraging Behat hooks
  • Multiple contexts
  • Loading Database fixtures and clearing data
  • Bootstrapping your application (specifically Symfony)
  • Using the authenticated user
  • Tagging scenarios
  • How to put BDD into practice
  • Keeping the velociraptors in their pen.

Let's do this!


Your Guides

Ryan Weaver Leanna Pelham

Questions? Conversation?

  • 2016-03-22 Dan Costinel

    I still experience an error when testing. Do you know why my test fails? http://imgur.com/Ts6E3w1

  • 2016-03-22 Dan Costinel

    Nevermind guys. I've missplaced the security. Instead of putting it in app/config/security.yml, I've placed it in app/config/config.yml... Sorry!

  • 2016-03-22 Dan Costinel

    Hello guys. I copied all the "finish" files into a fresh Symfony 2.7.10 project. I changed few things in your files, in order to make the project work, and I finally did it. Now I'm stuck at login, as I can't login with the provided credentials (user=admin, pass=admin). I've re-created the db with the link inside my app ( /_db/rebuild ) - nothing, I've deleted entirely my db, and I've re-created it with doctrine:database:create, and doctrine:schema:update --force, but still nothing. I get the same error message when I try to login: Invalid credentials. I tried to generate, online, the bcrypt hash for the string "admin" using http://bcrypthashgenerator.app..., and replacing the password field value within user table, but without any good result. Any ideas on how to solve it, maybe without re-creating all from the start? Thank you!!

  • 2016-01-19 weaverryan

    Hi Bartek!

    Yes, I have done this stuff before with a client (at least with iframes, but I think also with windows) - some of the details are fuzzy, but we were totally able to pull it off. As you probably already know, the key methods are on the Session: https://github.com/minkphp/Min.... I would use getWindowName() and getWindowNames() (https://github.com/minkphp/Min... to debug and figure out what all the window names are being called during the process.

    I know that's vague, but I hope it helps! Cheers!

  • 2016-01-19 Bartek

    Hi, How can I switch from one window to another. For example, my scenario is as follows -

    Scenario Outline: User login with Facebook
    When I press "siginFacebook"
    And I switch to the new tab
    And I fill in "<email>" for "email"
    And I fill in "<password>" for "pass"
    And Click the "u_0_2" select by "id"

    In this stage, as facebook login works, so popup window close automatically and it generates an error -
    "Window not found. The browser window may have been closed."

    Do you know how to come back to my original window after a successful facebook login?

  • 2015-10-13 weaverryan

    Hey!

    If you own the Behat 2.5 version, shoot us an email/contact message and we'll be happy to give anyone a coupon code to grab the 3.0 version free :).

    Cheers!

  • 2015-10-13 truthrevealer

    Should the owners of Behat 2.5 course purchase this one as well to get access to it?

  • 2015-10-13 Richard Bagshaw

    So much yes!! I want this one :) Behat 3!! :)