Search code examples
phplaravel-5.1behat

Behat - Undefined feature steps


I set up a simple test scenario to learn behat, but I'm running into some problems. I'm following THIS tutorial.

Here is my feature show:

Feature: show
    This is a behat feature to test the article pages.

##TODO
Scenario: I want to view a detailed article page
    Given I am logged in
        And I'm on "/articles"

    When I press an article Image

    Then I should see a title
        And I should see an Image
        And I should see some text

and here is my FeatureContext.php file

        <?php


        use Behat\MinkExtension\Context\MinkContext;



        /**
         * Features context.
         */
        class FeatureContext extends MinkContext
        {
            /**
             * Initializes context.
             * Every scenario gets its own context object.
             */
            public function __construct()
            {
            }

            /**
             * @Given /^I am on "([^"]*)"$/
             */
            public function iAmOn($arg1)
            {
                throw new PendingException();
            }

            /**
             * @Given /^I press "([^"]*)"$/
             */
            public function iPress($arg1)
            {
                throw new PendingException();
            }

            /**
             * @When /^I fill in "([^"]*)" with "([^"]*)"$/
             */
            public function iFillInWith($arg1, $arg2)
            {
                throw new PendingException();
            }

            /**
             * @Then /^I should see "([^"]*)" in the "([^"]*)" element$/


     */
        public function iShouldSeeInTheElement($arg1, $arg2)
        {
            throw new PendingException();
        }
}

However everytime I try to run the feature I get the same result, which looks like this:

Feature: show
  This is a behat feature to test the article pages.

  Scenario: I want to view a detailed article page # features\show.feature:5
    Given I am logged in
    And I'm on "/articles"
    When I press an article Image
    Then I should see a title
    And I should see an Image
    And I should see some text

1 scenario (1 undefined)
6 steps (6 undefined)
0m0.32s (4.78Mb)

I'm not sure what's causing this problem. I've been looking for a solution but I can't find it. I hope one of you can help me out!

thanks in advance


Solution

  • Your steps do not match your step definitions.

    You can let Behat create stubs of your step definitions by implementing SnippetAcceptingContext in your FeatureContext and running Behat with the --append-snippets argument as described here:

    http://behat.org/en/latest/quick_start.html#defining-steps