是否可以让子上下文类扩展另一个子上下文并覆盖函数?
目前我有
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() 中定义
有人可以指出我正确的方向吗?
为了提供一些关于我为什么要尝试实现这一点的更多信息,我想要实现的是能够在不同的环境中运行场景,并在小黄瓜文件中指定环境,例如:
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
来加载正确的子上下文。