gpt4 book ai didi

php - Behat - 未定义的特征步骤

转载 作者:搜寻专家 更新时间:2023-10-31 20:36:31 25 4
gpt4 key购买 nike

我设置了一个简单的测试场景来学习行为,但我遇到了一些问题。我正在关注 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)

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

提前致谢

最佳答案

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

您可以让 Behat 通过在您的 FeatureContext 中实现 SnippetAcceptingContext 并使用 --append-snippets 运行 Behat 来创建步骤定义的 stub 此处描述的参数:

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

关于php - Behat - 未定义的特征步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33809609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com