サブコンテキスト クラスに別のサブコンテキストを拡張させ、関数をオーバーライドさせることは可能ですか?
現在、私は
class TestContext extends BehatContext {
/**
* @Given /^a testScenarioExists$/
*/
public function aTestscenarioexists() {
echo "I am a generic test scenario\n";
}
}
と
class SpecialTestContext extends TestContext {
/**
* @Given /^a testScenarioExists$/
*/
public function aTestscenarioexists() {
echo "I am a special test scenario\n";
}
}
機能のコンテキストでは、サブコンテキストとしてそれを伝えますSpecialTestContext
。
テストビートを実行すると、
[Behat\Behat\Exception\RedundantException]
ステップ "/^a testScenarioExists$/" は SpecialTestContext::aTestscenarioexists() で既に定義されています
誰かがこれで正しい方向を教えてくれますか?
なぜこれを達成しようとしているのかについてさらに情報を提供するために、私が達成しようとしているのは、さまざまな環境でシナリオを実行し、gherkin ファイルで環境を指定する機能です。たとえば、次のようになります。
Scenario: Test with generic environment
Given I am in the environment "generic"
And a test scenario exists
Scenario: Test with specialised environment
Given I am in the environment "specialised"
And a test scenario exists
次に、いくつかのコードを追加FeatureContext
して、正しいサブコンテキストをロードできます。