我尝试将Behat 2项目迁移到Behat 3,但是我有问题要转换我的behat.yml。我对behat 2的behat.yml是:
default:
paths:
features: features
context:
parameters:
webserver_dir: /Users/bjoerne/Development/WebserverDocuments/wordpress-behat
webserver_url: http://localhost/wordpress-behat
install_files:
wordpress: wordpress-3.9.1-de_DE.zip
sqlite_integration: sqlite-integration.1.6.3.zip
disable_google_fonts: disable-google-fonts.1.0.zip
database_file: database_no_gravatar.sqlite
selenium_implicit_timeout: 10000
我为Behat 3改造了它:
default:
suites:
default:
paths: [ %paths.base%/features ]
contexts:
- FeatureContext:
- webserver_dir: /Users/bjoerne/Development/WebserverDocuments/wordpress-behat
webserver_url: http://localhost/wordpress-behat
install_files:
wordpress: wordpress-3.9.1-de_DE.zip
sqlite_integration: sqlite-integration.1.6.3.zip
disable_google_fonts: disable-google-fonts.1.0.zip
database_file: database_no_gravatar.sqlite
selenium_implicit_timeout: 10000
当我调用Behat时,抛出Symfony \ Component \ Yaml \ Exception \ ParseException。似乎Symfony / Yaml解析器无法解析配置。我为此开了一个问题:https://github.com/symfony/symfony/issues/11019,因为它包含序列映射中的序列映射(非常棘手,但那是Behat 3的方式,不是吗?)
我想使用哈希作为参数,因为它在Behat 2中很常见。因为我可以压扁我的参数并使用Behat 3提供的普通数组。但是后来我有太多的参数我的代码不是很干净。
我想知道我从Behat 2到3的转换是否正确。有同样问题的人吗?您有什么建议来解决这个问题?
更新:我尝试了以下不起作用:
1)没有 - 之前' webserver_dir'
default:
suites:
default:
paths: [ %paths.base%/features ]
contexts:
- FeatureContext:
webserver_dir: /Users/bjoerne/Development/WebserverDocuments/wordpress-behat
webserver_url: http://localhost/wordpress-behat
install_files:
wordpress: wordpress-3.9.1-de_DE.zip
sqlite_integration: sqlite-integration.1.6.3.zip
disable_google_fonts: disable-google-fonts.1.0.zip
database_file: database_no_gravatar.sqlite
selenium_implicit_timeout: 10000
结果:
Argument 1 passed to FeatureContext::__construct() must be of the type array, none given in /Users/bjoerne/Development/Source/ifttt-wordpress-bridge/features/bootstrap/FeatureContext.php on line 19
似乎没有参数传递给我的构造函数
2)移动" webserver_dir"到下一行并缩进所有参数
default:
suites:
default:
paths: [ %paths.base%/features ]
contexts:
- FeatureContext:
-
webserver_dir: /Users/bjoerne/Development/WebserverDocuments/wordpress-behat
webserver_url: http://localhost/wordpress-behat
install_files:
wordpress: wordpress-3.9.1-de_DE.zip
sqlite_integration: sqlite-integration.1.6.3.zip
disable_google_fonts: disable-google-fonts.1.0.zip
database_file: database_no_gravatar.sqlite
selenium_implicit_timeout: 10000
结果是一个例外:
[Symfony\Component\Yaml\Exception\ParseException]
You cannot define a sequence item when in a mapping in "/Users/bjoerne/Development/Source/ifttt-wordpress-bridge/behat.yml"