【发布时间】:2017-11-29 15:53:29
【问题描述】:
我希望在使用 Codeception 时能够在 Gherkin 功能文件中使用 PhpStorm 的“Go To Declaration”功能(Mac 上的Command + B)。但是,PhpStorm 似乎并没有弄清楚步骤的定义位置,并输出此警告:
未定义的步骤参考:[…]
当我使用 Behat 时,PhpStorm 了解步骤的定义位置。
重现步骤
mkdir codeceptioncd codeceptioncomposer require "codeception/codeception" --dev./vendor/bin/codecept bootstrap./vendor/bin/codecept generate:feature acceptance first- 在 PhpStorm 中打开项目目录。
- 确保 PhpStorm 知道 Codeception 已安装:
- 确保已安装 PhpStorm 插件 Gherkin 和 Codeception Framework。
- 向
tests/acceptance/first.feature添加一个步骤。 ./vendor/bin/codecept gherkin:snippets acceptance
这将产生以下代码。 (并非所有内容都包括在内 - 如果我需要添加任何内容,请告诉我。)
tests/acceptance/first.feature:
Feature: first
In order to ...
As a ...
I need to ...
Scenario: try first
When I visit "/"
tests/_support/AcceptanceTester.php:
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
/**
* @When I visit :arg1
*/
public function iVisit($arg1)
{
throw new \Codeception\Exception\Incomplete("Step `I visit :arg1` is not defined");
}
}
但是,PhpStorm 不知道iVisit() 在哪里。我该如何解决这个问题?
【问题讨论】:
标签: php phpstorm codeception behat gherkin