Reputation: 173
I am using behat on windows7 ..it's my fourth day of struggle today...I have written a feature
#homepage.feature
Feature: To test the Home page loads successfully.
Scenario:
Given I am in a session
When I request the page "index.php"
Then I should get some content
and defined steps
/**
* @Given /^I am in a session$/
*/
public function iAmInASession() {
$driver = new \Behat\Mink\Driver\Selenium2Driver(
'firefox', 'base_url'
);
global $session;
$session = new \Behat\Mink\Session($driver);
// start session:
$session->start();
}
/**
* @When /^I request the page "([^"]*)"$/
*/
public function iRequestThePage($page)
{
global $session;
$session->visit($page);
}
/**
* @Then /^I should get some content$/
*/
public function iShouldGetSomeContent()
{
global $session;
if( $session->getPage()->getContent() )
echo $session->getPage()->getContent();
else
throw new Exception("The page couln't load successfully!");
}
It's also showing me 147 undefined scenarios and 878 undefined steps from the default ones while some of the steps are defined in FeatureContext.php
Please Help!!!
Upvotes: 2
Views: 2235
Reputation: 173
I'm sorry , there were a couple of mistakes I was making ....I did not create the features directory , instead was adding my features to the vendor\behat\behat\features directory and the step definitions to vendor\behat\behat\features\bootstrap\FeatureContext.php
To make it work I had to create features directory in root of project by typing vendor\behat\behat\bin\behat --init in command prompt
All features should reside in this directory and steps should go in root\features\bootstrap\FeatureContext.php
Further the uri should be 'http://'.localhost/Project/.$page in $session->visit()
Hope this helps someone!
Upvotes: 1