Skip to content

Instantly share code, notes, and snippets.

@cystbear
Created November 16, 2011 20:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cystbear/1371256 to your computer and use it in GitHub Desktop.
Save cystbear/1371256 to your computer and use it in GitHub Desktop.
Behat meta steps -- tiny example
/**
* @Given /^I logged in as "([^"]*)" with "([^"]*)" password$/
*/
public function iLoggedInAsWithPassword($username, $password)
{
return array(
new Step\Given("I am on \"/login\""),
new Step\When("I fill in \"Username\" with \"$username\""),
new Step\When("I fill in \"Password\" with \"$password\""),
new Step\When("I press \"Login\""),
new Step\Then("I should be on \"/home\""),
);
}
Scenario: Test my feature
Given I am on "/login"
When I fill in "Username" with "admin"
And I fill in "Password" with "admin"
And I press "Login"
And I should be on "/home"
And I go to "/feature-page" # your start your real steps here
And ...
And ...
Then ...
And ...
And ...
Scenario: Test my feature
Given I logged in as "admin" with "admin" password
When I go to "/feature-page" # your start your real steps here
And ...
Then ...
And ...
@cordoval
Copy link

thanks this was useful

@OskarStark
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment