2014-12-18 2 views
0

저는 behat 2.4 (안정적)를 사용하고 있으며 BehatContext 클래스, 생성자를 확장하는 클래스에 매개 변수를 전달하려고합니다. 그러나 다음과 같이 설정하여 "behat"아래에 'Unrecognized options "suites"가 표시됩니다."behat"아래에 인식 할 수없는 옵션 "suites"

default: 
    suites: 
    default: 
     contexts: 
     exampleContext: 
      browser: http://localhost:8080 
      browser_version: /var/tmp 
    paths: 
    features: %behat.paths.base%/../../ 
    bootstrap: %behat.paths.base%/../../ 
    extensions: 
    Behat\MinkExtension\Extension: 
     # base_url is the URL to your dev site. Make sure you include 
     # the port at the end. e.g. 
     base_url: http://example.web01.com 
     default_session: selenium2 
     browser_name: 'chrome' 
     selenium2:      
     capabilities: { "browser": "firefox", "version": "14"} 
     sites/all/libraries/extensions/DrupalBehatExtension.php: ~ 
    filters: 
    # The default profile does not rebuild from nothing so do not run tests 
    # that require a rebuild from nothing. 
    tags: [email protected] 
    context: 
    class: DrupalContext 
    parameters: 
     # If you'd like to test on a clone of the actual site data set to true. 
     use_test_database: false 
     # If an existing test database exists then it will be used unless reset_database is set to true. 
     reset_database: false 
     # If you would like to clear the db and run site install on every feature 
     # set to the name of an install profile, otherwise set to false. 
     # If you do set this you should also set use_test_database to true. 
     rebuild_on_feature: false 
     # If you would like to enable a module after running site install 
     rebuild_module: false 
     # Set the name of the site folder to use for settings.php. 
     site: dev.example.com 

내 클래스 구현이

class exampleContext extends BehatContext { 


public function __construct($browser = 'ie', $browser_version = '8') { 
    ... 
} 

내가 어떻게 이것을 달성 할 수

나는 다음과 같은 behat.yml 파일을 사용하고 있습니다? 내가 찾은 유일한 대답은 드루팔 (DrupalContext)을 꺼내야한다는 것입니다. DrupalContext는 다소 중요합니다.

How can i get the Parameters from Behat.yml to a php file?

+2

'스위트 룸'옵션 IIRC는 behat에 추가 된 3 – l3l0

+0

답변으로 게시물을 l3l0 @하시기 바랍니다. –

답변

1

시도해보십시오. 이것은 Behat 2가 아니라 3입니다!

mySymfonyProject/composer.json :

"require": { 
    "behat/behat": "2.5.*@stable", 
    "behat/behat-bundle": "1.0.0", 
    "behat/symfony2-extension": "1.1.2", 
    "behat/mink": "1.5.0", 
    "behat/mink-extension": "~1.3", 
    "behat/mink-selenium2-driver": "1.1.1", 
    "behat/mink-goutte-driver": "1.0.9" 
}, 
"config": { 
    "bin-dir": "bin" 
}, 
"minimum-stability": "dev", 

CONTEXT 기능

default: 
    context: 
     class: FeatureContext 
     parameters: 
      browser: 'ie' 
      browser_version: '8' 
    extensions: 
     Behat\Symfony2Extension\Extension: 
      mink_driver: true 
      kernel: 
       env: test 
       debug: true 
     Behat\MinkExtension\Extension: 
      base_url: 'http://mysymfonyproject.local/app_test.php/' 
      javascript_session: selenium2 
      browser_name: firefox 
      goutte: ~ 
      selenium2: ~ 
    paths: 
     features: %behat.paths.base%/src 
     bootstrap: %behat.paths.features%/Context 

behat.yml

mySymfonyProject/SRC/사이트/CommonBundle/기능/컨텍스트/Fe atureContext.php

<?php 

namespace Site\CommonBundle\Features\Context; 

use Behat\MinkExtension\Context\MinkContext; 

class FeatureContext extends MinkContext 
{ 
    public function __construct($browser, $browser_version) 
    { 
     // Do whatever you wish with params 
    } 

    //And your own methods 
} 

TESTS

당신은 다음과 같이 실행할 수 있습니다 기능 파일이 (이 모두 한 번에 실행됩니다. 문서 behat 읽어 추가 정보)에 대한 :

bin/behat @SiteCommonBundle 
3

suites 옵션은 behat3에서 추가되었다. 버전을 업데이트해야합니다.