Behat / Mink没有为"然后"找到默认步骤声明

时间:2015-07-26 14:36:39

标签: php behat mink

我无法让Mink / Behat找到短语

的默认步骤
Then I should see "some text" in the element "element"

这是我的thepage.feature文件:

Feature: Page Works
  In order to use the page
  As a visitor
  I need to be able to load it and see content

Scenario: Navigating to the page
  Given I am on "mypage.php"
  #Then I should see "some text"
  #Then the "body" element should contain "sometext"
  #Then I should see "sometext" in the "body" element

我的FeatureContext扩展了MinkContext,所以我不明白为什么较低的两个Then语句是未定义的,但是上层语句可以正常工作。

  Scenario: Navigating to the page        # features\wikipedia.feature:6
    Given I am on "thepage.php"           # FeatureContext::visit()
    Then I should see "sometext" in the element "body"

1 scenario (1 undefined)
2 steps (1 undefined)

由于Given声明有效,我不明白可能出现的问题!当然它不能是yml文件或composer.json?

composer.json:

{
    "require": {
        "behat/behat": "2.4.*@stable",
        "behat/mink": "1.4.*@stable",
        "behat/mink-extension": "*",
        "behat/mink-goutte-driver": "*",
        "behat/mink-selenium2-driver": "*"
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}

behat.yml:

default:
  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://localhost
      goutte: ~
      selenium2: ~

问题还有什么地方?感谢

2 个答案:

答案 0 :(得分:1)

尝试使用

Then I should see "sometext" in the "body" element

而不是

Then I should see "sometext" in the element "body"

这是MinkContext method description

答案 1 :(得分:0)

尝试使用这些(从here获得):

<强> composer.json

"require-dev": {
    "behat/behat": "2.5.5",
    "behat/mink-extension": "1.3.3",
    "behat/mink": "1.5.0",
    "behat/symfony2-extension": "1.1.2",
    "behat/mink-selenium2-driver": "1.1.1",
    "behat/mink-browserkit-driver": "1.1.0",
    "behat/mink-goutte-driver": "1.0.9"
}

<强> behat.yml

default:
    formatter:
        name: pretty
        parameters:
            output_styles:
                comment: [ magenta ]
    context:
        class: Application\BackendBundle\Features\Context\FeatureContext
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://football.local/app_test.php/'
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

有关更多示例,look here