I'm experiencing problems with defining my own steps for BDD features in Behat and Mink setup in Yii framework.
I've successefully installed Behat with Mink extension following the instructions from MinkExtension-example.
After all that, I have the following structure of my folders inside myapp/private_html/ (some deeply nested folders were omitted):
├───bin
├───commands
│ └───shell
├───components
├───config
├───controllers
├───features
│ ├───bootstrap
│ └───php54_bootstrap
├───models
├───tests
├───vendor
│ ├───behat
│ │ ├───behat
│ │ │ ├───bin
│ │ │ ├───features
│ │ │ │ ├───annotations
│ │ │ │ ├───bootstrap
│ │ │ │ └───closures
└───views
A feature provided as an example in the above mentioned link MinkExtension-example works without a problem. But when I define my own step like
Scenario: presence of menu items
Given I am on "/"
Then I should see the following: "Home, About, Contact"
I get
1 scenario (1 undefined)
2 steps (1 passed, 1 undefined)
0m2.288s
with a suggestion
You can implement step definitions for undefined steps with these snippets:
/**
* @Then /^I should see the following: "([^"]*)"$/
*/
public function iShouldSeeTheFollowing($arg1)
{
throw new PendingException();
}
And the question is: where should I put this code? I've tried to put it in
myapp\private_html\features\bootstrap\FeatureContext.php
as well as in
myapp\private_html\vendor\behat\behat\features\bootstrap\FeatureContext.php
but the step remains undefined.
So, where are the steps supposed to be defined?
You never have to change vendor's code (I suppose you are using composer). Is not your code.
You code must to be added to features\bootstrap\FeatureContext.php.
Maybe the problem is that your FeatureContext class dont extends MinkContext but BehatContext. Y'll find a comment in FeatureContext's file. Change parent class of FeatureContext from BehatContext to MinkContext.
Finally, to see all sentences that your context can see, run "./bin/behat -dl". If you run this command before change Context, you can see that behat has few sentences.