Codeception, write acceptance tests with the pageObject design pattern and gherkin
I get "not found in contexts" warnings in my shell
Ok, how to link gherkin files execution with steps defined in my own contexts classes (PageObjects, StepObjects, ...)? We can read chapter "BDD > Configuration" in Codeception documentation:
As we mentioned earlier, steps should be defined inside context classes. By default all the steps are defined inside an Actor class, for instance, AcceptanceTester. However, you can include more contexts. This can be configured inside global codeception.yml or suite configuration file:
gherkin:
contexts:
default:
- AcceptanceTester
- AdditionalSteps
- PageHome
- HomeChekcer
(...) This way PageObjects, Helpers and StepObjects can become contexts as well.
Better
If we continue reading:
But more preferable to include context classes by their tags or roles.
This means that, bearing in mind escalability and good organization, you will not want to overload every tests with every Page Object. Therefore you can assign Page Object (or any assistant classes) by role, by tag or by paths. See next paragraphs on documentation. Following your example, and assigning by tag:
gherkin:
contexts:
default:
- AcceptanceTester
tag:
myTagX:
- Page\Acceotance\HomePage\HomeChecker
- Page\PageHome
anotherTag:
- Page\Acceotance\another\AnotherChecker
- Page\PageAnother
...and in gherkin files:
@myTagX
Feature
(...)