You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make a POC using Codeconcept with BDD. I've created a stepobject and I wanted to use this file for test steps. I've followed CONFIGURATION section to autoload the additional steps file since only context files can contain these. When I run php vendor/bin/codecept gherkin:steps Acceptance I get this as a result:
Steps from default context:
+-----------------------------------------+---------------------------------------------------------
| Step | Implementation
+-----------------------------------------+---------------------------------------------------------
| The user logs in with the default user. | Tests\Support\Step\Acceptance\LoginSteps::loginWithDefaultUser |
+-----------------------------------------+---------------------------------------------------------
When I run the test with php vendor/bin/codecept run --debug the test runs successfully, and when I run the test from PHPStorm itself, the test also runs successfully. Nonetheless the step is not recognised in the feature file and it is showed as an undefined step reference.
Below you can find all the specs, files, and steps I did:
Specs:
PHP version: 8.2.11
Codeception version: 5.0.11
System: Windows 10 / IDE: PHPStorm
Here are the steps I did:
I've installed codeconcept with composer require codeception/module-webdriver --dev
I've installed the webdriver module with composer require codeception/module-webdriver --dev --ignore-platform-req=ext-zip
I've run php vendor/bin/codecept bootstrap - this generated all suites
I've generated one pageobject file with php vendor/bin/codecept g:pageobject Acceptance Login
I've generated one stebobject file with php vendor/bin/codecept g:stepobject Acceptance LoginSteps
I've generated one feature file with php vendor/bin/codecept g:feature Acceptance coupon
This is how my directory looks like:
namespace Tests\Support\Page\Acceptance;
use Tests\Support\AcceptanceTester;
class Login
{
public string $accountField = "input[name='account']";
public string $emailField = "input[name='mail']";
public string $passwordField = "input[name='password']";
public string $loginButton = "button[type='submit']";
/**
* @var AcceptanceTester;
*/
protected AcceptanceTester $acceptanceTester;
public function __construct(AcceptanceTester $I)
{
$this->acceptanceTester = $I;
}
public function fillAccountField(string $account): void
{
$this->acceptanceTester->fillField($this->accountField, $account);
}
public function fillEmailField(string $email): void
{
$this->acceptanceTester->fillField($this->emailField, $email);
}
public function fillPasswordField(string $password): void
{
$this->acceptanceTester->fillField($this->passwordField, $password);
}
public function clickLoginButton(): void
{
$this->acceptanceTester->click($this->loginButton);
}
}
This is the content ofLoginSteps.php:
namespace Tests\Support\Step\Acceptance;
use Codeception\Attribute\When;
use Tests\Support\AcceptanceTester;
use Tests\Support\Page\Acceptance\Login;
class LoginSteps
{
protected AcceptanceTester $acceptanceTester;
public function __construct(AcceptanceTester $I)
{
$this->acceptanceTester = $I;
}
#[When('The user logs in with the default user.')]
public function loginWithDefaultUser(): void
{
$this->acceptanceTester->amOnPage("/");
$loginPage = new Login($this->acceptanceTester);
$loginPage->fillAccountField($_ENV['BRAND_NAME']);
$loginPage->fillEmailField($_ENV['DEFAULT_USERNAME']);
$loginPage->fillPasswordField($_ENV['DEFAULT_PASSWORD']);
$loginPage->clickLoginButton();
}
}
This is the content ofcoupon.feature:
Feature: coupon
Scenario: try coupon
* The user logs in with the default user. - THIS STEP IS NOT RECOGNIZED!
Am I missing something here?
The text was updated successfully, but these errors were encountered:
I'm trying to make a POC using Codeconcept with BDD. I've created a stepobject and I wanted to use this file for test steps. I've followed CONFIGURATION section to autoload the additional steps file since only context files can contain these. When I run
php vendor/bin/codecept gherkin:steps Acceptance
I get this as a result:Steps from default context:
When I run the test with
php vendor/bin/codecept run --debug
the test runs successfully, and when I run the test from PHPStorm itself, the test also runs successfully. Nonetheless the step is not recognised in the feature file and it is showed as an undefined step reference.Below you can find all the specs, files, and steps I did:
Specs:
PHP version: 8.2.11
Codeception version: 5.0.11
System: Windows 10 / IDE: PHPStorm
Here are the steps I did:
I've installed codeconcept with
composer require codeception/module-webdriver --dev
I've installed the webdriver module with
composer require codeception/module-webdriver --dev --ignore-platform-req=ext-zip
I've run
php vendor/bin/codecept bootstrap
- this generated all suitesI've generated one pageobject file with
php vendor/bin/codecept g:pageobject Acceptance Login
I've generated one stebobject file with
php vendor/bin/codecept g:stepobject Acceptance LoginSteps
I've generated one feature file with
php vendor/bin/codecept g:feature Acceptance coupon
This is how my directory looks like:
This is the content of
codeception.yml
:This is the content of
Acceptance.suite.yml
:This is the content of
Login.php
:This is the content of
LoginSteps.php
:This is the content of
coupon.feature
:Am I missing something here?
The text was updated successfully, but these errors were encountered: