我希望在使用Codeception时能够在Gherkin特性文件中使用PhpStorm的“Go To Declaration”功能(在Mac上为Command + B)。然而,PhpStorm似乎并没有揣摩出定义的步骤,并输出这样的警告:使用Codeception和黄瓜时PhpStorm中未定义的步骤参考
未定义一步参考:[...]
当我使用贝哈特,PhpStorm理解步骤已定义。
步骤来重现
mkdir codeception
cd codeception
composer require "codeception/codeception" --dev
./vendor/bin/codecept bootstrap
./vendor/bin/codecept generate:feature acceptance first
- 打开在PhpStorm项目目录。
- 确保PhpStorm知道安装Codeception:
- 确保安装了PhpStorm插件小黄瓜和Codeception框架。
- 添加一步到
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()
是。我怎样才能解决这个问题?
太好了,非常感谢。我从来没有想过(仍然不明白它为什么起作用)。 –