Behat 3: step execution chaining

251 views
Skip to first unread message

Krisztian Ferenczi

unread,
Jul 2, 2014, 5:18:37 AM7/2/14
to be...@googlegroups.com

Konstantin Kudryashov

unread,
Jul 3, 2014, 2:24:39 AM7/3/14
to be...@googlegroups.com
You can not out of the box. It is considered a bad practice.

Konstantin Kudryashov
--- PHP developer, BDD evangelist, Scrum master

a: http://about.me/everzet
b: http://everzet.com
c: https://github.com/everzet
--
You received this message because you are subscribed to the Google Groups "Behat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to behat+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

riccardo franconi

unread,
Jul 4, 2014, 2:44:42 AM7/4/14
to be...@googlegroups.com
Hi Konstantin.

Why is it consider a bad practice ?

Konstantin Kudryashov

unread,
Jul 4, 2014, 6:52:10 AM7/4/14
to be...@googlegroups.com
Because as soon as you start doing that you:

1. Can not refactor your contexts
2. Can not clearly see what the code actually does
3. Can not easily reword your features

And if you think that using inline steps is easier:

return array(
    new Step\Given(‘I am on the homepage’),
    new Step\When(‘I follow ”Login”’),
    new Step\When(‘I fill ”Username” with “‘ . $username . '"’),
    new Step\When(‘I fill ”Password” with “‘ . $password . '"’),
    new Step\When(‘I click “Login"’),
);

It is not:

$session = $this->getSession();
$page = $session->getPage();

$session->visit($this->locateUrl(‘/‘));
$page->clickLink(‘Login’);
$page->fillField(‘Username’, $username);
$page->fillField(‘Password’, $password);
$page->pressButton(‘Login’);

Kind regards,

Konstantin Kudryashov
--- PHP developer, BDD evangelist, Scrum master

a: http://about.me/everzet
b: http://everzet.com
c: https://github.com/everzet

riccardo franconi

unread,
Jul 4, 2014, 9:28:37 AM7/4/14
to be...@googlegroups.com
Thanks!

regards.
Reply all
Reply to author
Forward
0 new messages