我正在使用behat 2.4(稳定版),我正在尝试将参数传递给类,这扩展了BehatContext类,构造函数。 但是我得到了“无法识别的选项"套房"在" behat"'下进行以下设置。
我正在使用以下behat.yml文件:
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: ~@require-rebuild
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') {
...
}
我怎样才能做到这一点?我找到的唯一答案是要求取出DrupalContext,这是非常重要的。
答案 0 :(得分:3)
suites
选项。你应该更新版本。
答案 1 :(得分: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",
<强> behat.yml 强>
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
上下文功能
<强> mySymfonyProject / SRC /站点/ CommonBundle /功能/背景/ FeatureContext.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 doc):
bin/behat @SiteCommonBundle