magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Can't run unit test #36702

Closed rogerdz closed 1 year ago

rogerdz commented 1 year ago

Preconditions and environment

Steps to reproduce

run command: ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist

(doc: https://developer.adobe.com/commerce/testing/guide/unit/command-line/)

Expected result

no error

Actual result

Error: Config file allure/allure.config.php doesn't exist

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @rogerdz. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://48187f8af7b3394aae62c612e4d5a37e.instances.magento-community.engineering Admin access: https://48187f8af7b3394aae62c612e4d5a37e.instances.magento-community.engineering/admin_06c5 Login: 6c9a9650 Password: 46aff5d1a042

engcom-Bravo commented 1 year ago

Hi @rogerdz,

Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Steps to reproduce

run command: ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist

We are getting Error: Config file allure/allure.config.php doesn't exist

Screenshot 2023-01-05 at 11 19 02 AM

Hence confirming the issue.

Thanks.

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-7698 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

sta1r commented 1 year ago

Removing this block from dev/tests/unit/phpunit.xml.dist will fix this temporarily:

<extensions>
        <extension class="Qameta\Allure\PHPUnit\AllureExtension">
            <!-- Optional arguments block; omit it if you want to use default values -->
            <arguments>
                <!-- Path to config file (default is config/allure.config.php) -->
                <string>allure/allure.config.php</string>
            </arguments>
        </extension>
    </extensions>
hostep commented 1 year ago

https://github.com/magento/magento2/pull/36703 also fixes it (but why is it marked as WIP @rogerdz?)

rogerdz commented 1 year ago

@hostep because changed made run unit test fail via command php bin/magento dev:tests:run unit

glo71317 commented 1 year ago

@rogerdz This issue is happening because we made changes to run unit test in 2.4.6 release. Now 2.4-develop is synced so this issue will not be reproduced. As we have already verified at our end so, Can you please verify at your end?

convenient commented 1 year ago

Now 2.4-develop is synced so this issue will not be reproduced.

@glo71317 what exactly was synced / changed to fix this issue?

glo71317 commented 1 year ago

We will check this issue and come back

hostep commented 1 year ago

@glo71317

@rogerdz This issue is happening because we made changes to run unit test in 2.4.6 release. Now 2.4-develop is synced so this issue will not be reproduced. As we have already verified at our end so, Can you please verify at your end?

I'm still running against this issue on the latest 2.4-develop branch:

$ vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist setup/src/Magento/Setup/Test/Unit/
Config file allure/allure.config.php doesn't exist

The change from https://github.com/magento/magento2/pull/36703 fixes it for me.

glo71317 commented 1 year ago

@hostep I have checked and found only issue will fixed by https://github.com/magento/magento2/pull/36703 fix. which occurring with this command "./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist", But when we are running unit test through PHPStrom this fix is not working. Hence, Will have a look the proper fix

hostep commented 1 year ago

Looks like this got fixed by https://github.com/magento/magento2/commit/57e33cc25cfd459cd52abcd3234b6cb546496935 (after some quick testing, it indeed seems to work)

engcom-Bravo commented 1 year ago

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-7698 by the internal team Related commits:https://github.com/search?q=repo%3Amagento%2Fmagento2+AC-7698&type=commits

Based on the Jira ticket, the target version is 2.4.7-beta1.

Thanks

hostep commented 1 month ago

Unfortunately this issue was reintroduced, probably over here: https://github.com/magento/magento2/commit/742c2f927077b69530c299aac3cbb27826087cf1#diff-7a02a9acfbb970097564f499f9b2fbae8ee5067818b5e48273370f845593cfda

When trying to run unit tests locally, I'm getting this error again now:

$ vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist path/to/some/php/file.php
...

1) Bootstrapping of extension Qameta\Allure\PHPUnit\AllureExtension failed: Config file allure/allure.config.php doesn't exist
...

@nishant04412: what would be your proposal to get around this?

nishant04412 commented 1 month ago

@hostep Thank you for pointing this out.

After some quick testing, it seems to be path related issue again. Usage of extensions is changed in PHPUnit 10 so parameter is used instead of extension in phpunit.xml extensions config. For now, I believe using below code should work for CLI as a workaround:

<extensions>
        <bootstrap class="Qameta\Allure\PHPUnit\AllureExtension">
            <!-- Path to config file (default is config/allure.config.php) -->
            <parameter name="config" value="dev/tests/unit/allure/allure.config.php" />
        </bootstrap>
</extensions>

This code might not work with PhpStorm though. This is initial analysis and we'll be required to find common solution again which supports PHPUnit 10 xml extensions configuration. I have created an issue for this:

https://jira.corp.adobe.com/browse/AC-13044

We'll update once this issue is resolved.

rogerdz commented 1 month ago

I using code for run unit test: cd dev/tests/unit/ && ../../../vendor/bin/phpunit -c phpunit.xml.dist ../../../path/to/some/php/file.php