2016-04-26 52 views
0

我有一個功能文件夾是根目錄,並在一個子目錄內我有文件夾稱爲公共與2功能上下文類。 SignIn.php和PostProject.phpBehat無法找到我的上下文類

我指定了behat.yml文件中的上下文類的路徑,它一直告訴我上下文類沒有找到並且不能被使用?我真的不知道它如何找不到它。

我不知道如何解決這個問題......它對我來說是正確的,不知道我做錯了什麼。

任何幫助將非常感激。以下是我的behat.yml文件

default: 
    suites: 
     public: 
      paths:  [%paths.base%/features/public] 
      contexts: 
       - PostProject 
       - SignIn 
       - Behat\MinkExtension\Context\MinkContext 
    extensions: 
     Behat\MinkExtension: 
     goutte: ~ 
     selenium2: ~ 

回答

0

我找到了答案。

上下文類需要通過其名稱空間自動加載。它需要在behat.yml文件中指定。路徑上下文用於特性測試(test.feature)文件

這裏是訂正.yml文件

default: 
    autoload: 
     '': %paths.base%/features 
    suites: 
     public: 
      paths:  [%paths.base%/features] 
      contexts: 
       - public1\PostProject 
       - public1\SignIn 
       - Behat\MinkExtension\Context\MinkContext 
     client: 
      paths:  [%paths.base%/features] 
      contexts: 
       - Client 
    extensions: 
     Behat\MinkExtension: 
     goutte: ~ 
     selenium2: ~ 

上下文類的實施例

namespace public1; 

date_default_timezone_set("America/New_York"); 
use Behat\Behat\Context\Context; 
use Behat\Behat\Context\SnippetAcceptingContext; 
use Behat\Behat\Hook\Scope\BeforeScenarioScope; 

/** 
* Defines application features from the specific context. 
*/ 
class SignIn implements Context, SnippetAcceptingContext 
{ 
//Content here 
} 



namespace public1; 

date_default_timezone_set("America/New_York"); 
use Behat\Behat\Context\Context; 
use Behat\Behat\Context\SnippetAcceptingContext; 
use Behat\Behat\Hook\Scope\BeforeScenarioScope; 

/** 
* Defines application features from the specific context. 
*/ 
class PostProject implements Context, SnippetAcceptingContext 
{ 
//Content here 
}