Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate declaration of canSeeCookie() #5500

Closed
Tscheffrey opened this issue May 8, 2019 · 9 comments

Comments

Projects
None yet
4 participants
@Tscheffrey
Copy link

commented May 8, 2019

What are you trying to achieve?

I am trying to execute codeception with two comma-separated parameters:

./codecept.phar run -c ../.. --env fast,prod

What do you get instead?

The method canSeeCookie() appears to be generated twice in _support/_generated/AcceptanceTesterActions.php.

PHP Fatal error:  Cannot redeclare Company\Test\Site\_generated\AcceptanceTesterActions::canSeeCookie() in /Users/username/Sites/example.localhost/tests/_support/_generated/AcceptanceTesterActions.php on line 180

Everything works just fine if if execute it with only one --env parameter

Details

  • Codeception version: 3.0.0
  • PHP Version: 7.0.33
  • Operating System: macOS
  • Installation type: Phar
  • Suite configuration:

acceptance.suite.yml:

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
        - Asserts

codeception.yml:

namespace: Company\Test\Site
actor: Tester
paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    shuffle: true
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        WebDriver:
            url: 'http://example.localhost'
            browser: chrome
env:
    local:
    stage:
        modules:
            config:
                WebDriver:
                    url: 'http://prev.example.de'
                    browser: chrome
    prod:
        modules:
            config:
                WebDriver:
                    url: 'http://example.com'
                    browser: chrome
    fast:
@Tscheffrey

This comment has been minimized.

Copy link
Author

commented May 8, 2019

@diverent2

This comment has been minimized.

Copy link

commented May 8, 2019

Have you tried to rebuild you generated fuctions, using

$ codeception build

?
Also are you using any globally declared functions like in acceptanceTester.php or helpers?
Make sure your project doesn't include a native codeception function name by accident ex.
Having named a function the same as an $I function or another codeception function name.

@Tscheffrey

This comment has been minimized.

Copy link
Author

commented May 8, 2019

Have you tried to rebuild you generated fuctions, using

$ codeception build
?

yes, AcceptanceTesterActions.php seems to be generated properly, but on execution the file is being regenerated again with two versions of the method

@DanielRuf

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

with two versions of the method

Two exact same methods. It is actually duplicated.
I guess there are probably more duplicated methods then?

@diverent2

This comment has been minimized.

Copy link

commented May 8, 2019

Here´s what we´ve leared so far:

The issue arrives whenever we try to run tests using multiple envs.

running from inside ./tests

$ ./tools/codecept.phar run -c .. --env local,fast acceptance

For whatever reason, run seems to be executing a build (maybe trying to combine the two envs?) to create the desired environment.

👉 In fact it will rebuild ./_support/_generated and will duplicate all functions starting with can or cant eg. canSeeInFormFields or cantSeeElement.

It appears to me that something having to do with the CLI -c config option path resolving is not working as expected.
Maybe it has to do with the version differences from root ^2.5. and the current 3.0 codecept.phar we are using to be able to use the new features without upgrading our project typo3-core.

@diverent2

This comment has been minimized.

Copy link

commented May 8, 2019

temporary solution

generating the functions using

$ ./tools/codecept.phar build -c ..

and then executing our files with the option --no-rebuild enabled

$ ./tools/codecept.phar run -c .. --env local,fast acceptance --no-rebuild

sets up the correct environment and works as expected.

the bug remains

I´m still pretty sure this is a bug.
Rebuilding the actor classes is also supposed to work using -c and multiple --envs.

Possibly related to: #5017, #5254

@Tscheffrey

This comment has been minimized.

Copy link
Author

commented May 9, 2019

thanks @diverent2 , --no-rebuild works fine for me!

@Naktibalda

This comment has been minimized.

Copy link
Member

commented May 26, 2019

Fixed in 3.0.1

@Naktibalda Naktibalda closed this May 26, 2019

@DanielRuf

This comment has been minimized.

Copy link
Contributor

commented May 26, 2019

Fixed in 3.0.1

Awesome =) Many thanks for taking the time to fix this and especially for maintaining Codeception 🙇 @DavertMik @Naktibalda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.