I'm writing a Gherkin-based acceptance testing PoC. I have a feature file, step object, and a page object. In my sequence I will need to log-in the test user before conducting the rest of the series. Our SUT is a legacy PHP application that didn't use any framework.
I would like to store the testuser's credentials in a params.yml or other external config file but have been unsuccessful in making this work and unable to find a complete example.
My login object is a simple Cest class for now. I didn't think it needed its own feature description, the rest of the tests will be Gherkin based where needed. My config files are currently the default configs generated by Codeception 5's bootstrap command with a gherkin section added for the one feature file I've written so far. Eventually I will run this under WebDriver to enable sessions...for now I'm just trying to establish a reusable environment we can build on for a team of developers.
The Codeception docs seem to gloss over some of these concepts or recommendations for users new to their framework.
I sincerely appreciate any ideas or concerns you may have.
<?php
namespace Tests\Acceptance;
use Codeception\Attribute\Group;
use Tests\Support\AcceptanceTester;
use Tests\Support\Page\Acceptance\LoginPage;
class LoginCest
{
#[Group('login')]
public function successfulLogin(AcceptanceTester $I, LoginPage $loginPage)
{
$loginPage->login( <testUserHere>, <goodPasshere> ); // <-this is what I want to provide
$I->dontSeeElement('.alert-error');
$I->amOnPage("/command.php");
}
public function unsuccessfulLogin(AcceptanceTester $I, LoginPage $loginPage)
{
$loginPage->login(getenv( <testUserHere> , 'baddpass');
$I->seeElement('.alert-error');
$I->amOnPage("/");
}
}