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

Error when running tests after upgrading from version 4 to 5 #6699

Open
vdanielpop opened this issue Oct 6, 2023 · 2 comments
Open

Error when running tests after upgrading from version 4 to 5 #6699

vdanielpop opened this issue Oct 6, 2023 · 2 comments

Comments

@vdanielpop
Copy link

What are you trying to achieve?

Hello,
I upgraded the version used in our project from 4.1.31 to latest because I wanted to see how I could make use of the new sharding mechanism. As a side-note, the issue that made us think about parallelization is that we noticed that the tests run significantly longer the more of them we run; so we wanted to check how they run in parallel. But anyway, that's a different story for which I will probably open another issue.

When I re-ran the test suite after the upgrade the first test seems to be running as expected, however the following one fails with this error:

                                            
  [PHPUnit\Framework\AssertionFailedError]  
  Client is not initialized

What do you get instead?

Full error output
In Assert.php line 2863:
                                          
[PHPUnit\Framework\AssertionFailedError]  
Client is not initialized                 
                                          

Exception trace:
at /var/www/vendor/phpunit/phpunit/src/Framework/Assert.php:2863
PHPUnit\Framework\Assert::fail() at /var/www/vendor/codeception/lib-asserts/src/Codeception/Util/Shared/InheritedAsserts.php:1185
Codeception\Module->fail() at /var/www/vendor/codeception/module-symfony/src/Codeception/Module/Symfony.php:291
Codeception\Module\Symfony->getClient() at /var/www/vendor/codeception/module-symfony/src/Codeception/Module/Symfony/BrowserAssertionsTrait.php:30
Codeception\Module\Symfony->rebootClientKernel() at /var/www/tests/_support/Helper/MockedServiceContainer.php:75
App\Tests\Helper\MockedServiceContainer->restoreMockedServices() at /var/www/tests/_support/Helper/MockedServiceContainer.php:44
App\Tests\Helper\MockedServiceContainer->_after() at /var/www/vendor/codeception/codeception/src/Codeception/Subscriber/Module.php:80
Codeception\Subscriber\Module->after() at /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php:230
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php:59
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /var/www/vendor/codeception/codeception/src/Codeception/Test/Test.php:291
Codeception\Test\Test->fire() at /var/www/vendor/codeception/codeception/src/Codeception/Test/Test.php:237
Codeception\Test\Test->realRun() at /var/www/vendor/codeception/codeception/src/Codeception/Suite.php:130
Codeception\Suite->run() at /var/www/vendor/codeception/codeception/src/Codeception/SuiteManager.php:148
Codeception\SuiteManager->run() at /var/www/vendor/codeception/codeception/src/Codeception/Codecept.php:260
Codeception\Codecept->runSuite() at /var/www/vendor/codeception/codeception/src/Codeception/Codecept.php:216
Codeception\Codecept->run() at /var/www/vendor/codeception/codeception/src/Codeception/Command/Run.php:646
Codeception\Command\Run->runSuites() at /var/www/vendor/codeception/codeception/src/Codeception/Command/Run.php:467
Codeception\Command\Run->execute() at /var/www/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at /var/www/vendor/symfony/console/Application.php:1040
Symfony\Component\Console\Application->doRunCommand() at /var/www/vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at /var/www/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at /var/www/vendor/codeception/codeception/src/Codeception/Application.php:112
Codeception\Application->run() at /var/www/vendor/codeception/codeception/app.php:45
{closure}() at /var/www/vendor/codeception/codeception/app.php:46
require() at /var/www/vendor/codeception/codeception/codecept:7
include() at /var/www/vendor/bin/codecept:117

Details

  • Codeception version: 5.0.11
  • PHP Version: 8.1.23
  • Operating System: Ubuntu 22.04.03 LTS
  • Installation type: Composer
@Naktibalda
Copy link
Member

I don't think that this error is directly related to upgrade to Codeception 5.
It happens in Symfony module and content of your App\Tests\Helper\MockedServiceContainer class may be very important.

@vdanielpop
Copy link
Author

Thanks for the fast reply @Naktibalda . I don't know how I missed the traces of MockedServiceContainer, I managed to discover what was causing that error.

However another strange behavior came up after fixing that one:
I have a test definition with the following details:

Feature file:
And I have a product with price "1234.5678"

Implementation:

    /**
     * @Then I have a product with price :price
     */
    public function theProductHasTheGivenPrice(float $price): void {...}

This used to work just fine with the previous version, and by that I mean that $price was correctly passed as float when the method was being called.
However after the update, it comes as string.

Argument #1 ($price) must be of type float, string given, called in /var/www/vendor/codeception/codeception/src/Codeception/Test/Gherkin.php on line 185

I've looked up if there are ways to specify in the feature file that I want value X to represent a float, but I haven't found anything along those lines. I'm not sure if the behaviour of the previous version where the value was type-casted was intended or not. Have you encountered this before ?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants