Preconditions (*)
- 1.Magento 2.3.1 upgraded from Magento 2.3.0
- Php 7.2.15
- OS : Ubuntu 18.04 Bionic
- Phpstorm 2019.1.1
- Evnironemnt : Magento development
Steps to reproduce (*)
- Issue appears after upgrading magento from 2.3.0 to 2.3.1 and run below commands.
- bin/magento dev:tests:run unit
- vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist.
- Above commands will work if version 2.3.0 is installed directly and also for 2.3.1 if installed directly.
These commands should run unit test on entire magento project not just on one mdoule.
Error (*)
Fatal error: Class 'Codeception\Platform\Extension' not found in
/var/www/html/magento23demo/vendor/allure-framework/allure-codeception/src/Yandex/Allure/Adapter/AllureAdapter.php
on line 49
Please note I can't find Platform\Extension codeception library in vendor folder.
Best Answer
BackGround: Problem occurred after using the cli upgrade method method mentioned here. First enable the maintenance mode so that website becomes inaccessible.
For upgrade following command was used
This command will only update the composer.json file "require" key. Because of --no-update flag it will not install the new magento version along with new packages. This can be verified from composer.lock file which contains the list of all currently installed packages. Search for magento/product-community-edition in composer.lock file it will still how the version to be 2.3.0.
Now if you run below unit test command it will work fine as magento is still 2.3.0 version.
Moving on above error(Class 'Codecception\Platform\Extension' not found) is related to allure-framework package in vendor directory.
Observe the Adapter/AllureAdapter.php file. This will change after update.
With magento version 2.3.0, mftf version 2.3.9 gets installed as can be noted in "require-dev" key of composer.json file.
Now run
This will update your magento installation and you will see numerous packages gets updates. Few but not all updates are shown in snap below. Total updated 173 and 11 new installs. Also your composer.lock file will be updated as well.
Again run and you will see that the error mentioned in this question will appear.
Solution:
Remove your current package magento/magento2-functional-testing-framework package which is version 2.3.9 as follows
You will notice this command will remove numerous packages along with following packages shown in pictures below
Now since allure-framework and mftf 2.3.9 has been removed we can install latest mftf version suitable for magento version 2.3.1 as follows.
Notice it will install latest version of allure-framework and mftf along with many other packages. Snap below
Now notice that allure-framework with allure-codeception and allure-php-api folders.
Now again run
You will see that a new error(below) will appear which means previous error (Class 'Codeception\Platform\Extension' not found) is resolved.
It can be resolved as follows
A vanilla installation of magento 2.3.1 was done and it was observed that a new folder allure-phpunit is added into allure-framework as given in picture below
Hence install allure-phpunit into your upgraded magento 2.3.1 as follows
This will give following error
phpunit/phpunit version is 6.5.0 in composer.json both in upgraded magento 2.3.1 and in vanilla installed 2.3.1. Hence allure-framework/allure-phpunit version 1.3 which is latest version will not be installed as it required phpunit/phpunit >=7.0.0.
So install
It will install latest 1.2 version of phpunit/phpunit compatible to upgraded magento 2.3.1 installation.
Now run again
SUCCESS !! phpunit test will start running for the entire project with following command line output. A snippet is given below