さまざまな機能にさまざまなコンテキスト クラスを使用する方法があるかどうか疑問に思っています。
1 つの機能でブラウザー テストに MinkExtensions を使用し、別の機能で API テストに Guzzle のような HTTP クライアントを使用したいと考えています。どちらも実装が異なる同様の手順になります。
さまざまな機能にさまざまなコンテキスト クラスを使用する方法があるかどうか疑問に思っています。
1 つの機能でブラウザー テストに MinkExtensions を使用し、別の機能で API テストに Guzzle のような HTTP クライアントを使用したいと考えています。どちらも実装が異なる同様の手順になります。
Behat 3 で可能になるはずです。http://everzet.com/tagged/Behat 機能を参照してください: 「タグごと、ディレクトリごと、ロールごとのコンテキスト クラスをサポートするマルチコンテキスト実行。この「ロールの重要性」 「私がいつも説いていたマントラは、最終的に各役割が独自のステップ辞書を持つことができるようになるので、ついに可能になります。」
現時点では、Behat 2 では、機能を分離するために異なるプロファイルを使用できます。behat.yml には、次のようなものがあります。
#running login suite using Mink
login-suite:
paths:
features: features/login-suite
bootstrap: features/login-suite/bootstrap
extensions:
mink-extension.phar:
base_url: http://domain.org
formatter:
name: pretty, junit, html
parameters:
output_path: null, logs/login-suite/, logs/login-suite/out.html
#running logout suite using the WebApi
logout-suite:
paths:
features: features/logout-suite/
bootstrap: features/logout-suite/bootstrap/
formatter:
name: pretty, junit, html
parameters:
output_path: null, logs/login-suite/, logs/logout-suite/out.html
extensions:
Behat\WebApiExtension\Extension:
base_url: http://api.domain.org
login-suite 機能と logout-suite 機能の FeatureContext.php ファイルが分離されました。
問題は、すべてのテストを一度に実行できないことです。コンテキストを使用してそうすることが可能かもしれません: http://docs.behat.org/guides/7.config.html#Context