我希望在使用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()
是。我怎樣才能解決這個問題?
太好了,非常感謝。我從來沒有想過(仍然不明白它爲什麼起作用)。 –