하위 컨텍스트 클래스를 사용하여 다른 하위 컨텍스트를 확장하고 함수를 재정의 할 수 있습니까? 현재behat 컨텍스트에서 단계 정의를 재정의 할 수 있습니까?
는 나는 그것을 우리에게 하위 컨텍스트로 SpecialTestContext
에게 기능의 맥락에서
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";
}
}
있습니다.
나는 시험 behat이
단계 "/^testScenarioExists $ /"이미 SpecialTestContext에 정의되어 :: aTestscenarioexists() [\ 예외 \의 RedundantException Behat \ Behat]
에 불만을 실행하면
누군가 내게 이것을 올바른 방향으로 가르쳐 주시겠습니까?
다른 환경에서 시나리오를 실행하고 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
에 몇 가지 코드를 추가하여 올바른 하위 컨텍스트를로드 할 수 있습니다. 한마디로
위에서 제공된 링크 만 업데이트하면됩니다. * http://docs.behat.org/en/latest/user_guide/context/definitions.html#redundant-step-definitions * http://docs.behat.org/ko/latest/user_guide/context. html # contexts-lifetime – aczietlow