vendredi 18 mai 2018

Feature Context error-already defined

I am trying to learn behat and this is my first try and do not seem to understand what is incorrect.

My composer.json is as following:

    {
        "require": {
           "behat/behat": "^3.4",
        "behat/mink": "^1.7",
        "behat/mink-extension": "^2.3",
        "symfony/dependency-injection": "3.3.13"
        }
    }

    **my behat.yml file is as:**
    default:
        extensions:
            Laracasts\Behat:
                # env_path: .env.behat
            Behat\MinkExtension:
                default_session: laravel
                base_url: http://localhost:8000
                laravel: ~

    **My FeatureContext.php file is as:**

    <?php

    use Behat\Behat\Context\Context;
    use Behat\Gherkin\Node\PyStringNode;
    use Behat\Gherkin\Node\TableNode;
    use Behat\MinkExtension\Context\MinkContext;


    /**
     * Defines application features from the specific context.
     */
    class FeatureContext extends MinkContext implements Context
    {
        /**
         * Initializes context.
         *
         * Every scenario gets its own context instance.
         * You can also pass arbitrary arguments to the
         * context constructor through behat.yml.
         */
        public function __construct()
        {
        }

        /**
         * Opens homepage.
         *
         * @Given /^(?:|I )am on (?:|the )homepage$/
         * @When /^(?:|I )go to (?:|the )homepage$/
         */
        public function IAmAtHomepage()
        {

            $this->visitPath('/');
        }
        /**
         * Checks, that page contains specified text.
         *
         * @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
         */
        public function assertPageContainsText($text)
        {
            $this->assertSession()->pageTextContains($this->fixStepArgument($text));
        }
    }

**Here is my feature file**
Feature:
  In order to prove that Behat works as intended
  We want to test the home page for a phrase

  Scenario: Root Test
    When I am on the homepage
   Then I should see "Laravel 5"

I get this following error:

Scenario: Root Test # features/hometest.feature:5 When I am on the homepage Step "/^(?:|I )should see "(?P(?:[^"]|\")*)"$/" is already defined in FeatureContext::assertPageContainsText()

  FeatureContext::assertPageContainsText()
  FeatureContext::assertPageContainsText()
Then I should see "Laravel 5"
  Step "/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/" is already defined in FeatureContext::assertPageContainsText()

  FeatureContext::assertPageContainsText()
  FeatureContext::assertPageContainsText()

--- Failed scenarios:

features/hometest.feature:5

1 scenario (1 failed) 2 steps (2 failed) 0m0.01s (15.18Mb)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wQfSyE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire