如何在Behat 3.0中使用子上下文

rkm*_*max 4 bdd symfony behat

在behat 2.5如果我想分割我的步骤定义我只需要创建多个clases

class FeatureContext extends MinkContext
{    
    public function __construct(array $parameters)
    {
        // Initialize your context here
        // ...
        $this->useContext('SubContextA', new SubContextA($parameters));
        $this->useContext('SubContextB', new SubContextB($parameters));
    }
}
Run Code Online (Sandbox Code Playgroud)

但3.0分支是完全不同的Context不扩展它们实现SnippetAcceptingContext并使用像KernelDictionary这样的特性.

我如何在Behat 3.0中使用"subcontexts",文档真的很差

Ian*_*hek 6

文档确实很差.AFAIK你没有子上下文,相反,你现在可以为每个套件定义多个上下文.

# behat.yml

default:
    suites:
        domain_features:
            paths:    [ %paths.base%/features ]
            contexts: [ DomainContext ]
        web_features:
            paths:    [ %paths.base%/features ]
            contexts: [ WebContext ]
            filters:
                tags: @web
Run Code Online (Sandbox Code Playgroud)