Is it possible to have have a subcontext class extend another subcontext and override functions?
At present I have
class TestContext extends BehatContext {
/**
* @Given /^a testScenarioExists$/
*/
public function aTestscenarioexists() {
echo "I am a generic test scenario\n";
}
}
and
class SpecialTestContext extends TestContext {
/**
* @Given /^a testScenarioExists$/
*/
public function aTestscenarioexists() {
echo "I am a special test scenario\n";
}
}
In feature context I tell it us the SpecialTestContext
as a subcontext.
When I run the test behat complains with
[Behat\Behat\Exception\RedundantException]
Step "/^a testScenarioExists$/" is already defined in SpecialTestContext::aTestscenarioexists()
Can somebody please point in me the right direction with this ?
To give some further info as to why I'm trying to achieve this what I am trying to achieve is the ability to run scenarios with different environments, and have the environment specified in the gherkin file, for example:
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
I then can use add some code in FeatureContext
to load up the correct sub-context.