PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php-Behat-未定义的功能步骤大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我设置了一个简单的测试场景来学习behat,但是我遇到了一些问题.我正在关注THIS教程.

这是我的专题节目:

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

这是我的FeatureContext.PHP文件

        <?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();
        }
}

但是,每次我尝试运行该功能时,都会得到相同的结果,如下所示:

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)

我不确定是什么引起了这个问题.我一直在寻找解决方案,但找不到.我希望你们中的一个能帮助我!

提前致谢

解决方法:

您的步骤与步骤定义不匹配.

您可以通过在FeatureContext中实现SnippetAcceptingContext并使用–append-snippets参数运行Behat来让Behat创建步骤定义的存根,如下所述:

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

大佬总结

以上是大佬教程为你收集整理的php-Behat-未定义的功能步骤全部内容,希望文章能够帮你解决php-Behat-未定义的功能步骤所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: