I am learning to use Codeception. In the Writing a Sample Scenario documentation, one mentions a $scenario
variable.
Say I implement a MyAcceptanceTester
class, is this some kind of parameters variable I can use to control the behavior of my Actor? Or is this a reserved variable in the Codeception paradigm? If so, how does it work?
My testing need is the following: I need to run the same sequence of actions on several domain names. It's a case where one domain name is used per language, but all code is in the same code base and is delivered by the same Apache server. Each domain may have its own PHP code, but also shares common code with other domains. Hence, Codeception testing code will be located in the unique code base.
I was thinking about passing each URL/URI to test in MyAcceptanceTester
via the $scenario
variable. Is this the right way to proceed? Or should I subclass MyAcceptanceTester
for each domain, because $scenario
is reserved?
The $scenario
variable on your *Cept.php
file actually an variable assigned to construct the AcceptanceTester
class. To inspect how it's work you may open AcceptanceTester
class file in test/_support/AcceptanceTester.php
. If you see AcceptanceTester
class is extended from Codeception\Actor
class. Follow this source to read how $scenario
variable used by the Actor
.
About your case.
I need to run the same sequence of actions on several domain names.
You can implement a technic called StepObject
(documentation). So the test for each website will extend from StepObjet
that you recently created.
Hope it helps.