Skip to content

33294 eliminate aspectmock from allureHelperTest #839

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

Conversation

SilinMykola
Copy link

Description

Eliminate AspectMock usage from dev/tests/unit/Magento/FunctionalTestFramework/Allure/AllureHelperTest.php

Fixed Issues

  1. [MFTF] Eliminate AspectMock from AllureHelperTest (Complex!) magento2#33294: [MFTF] Eliminate AspectMock from AllureHelperTest (Complex!) #33294

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

@SilinMykola SilinMykola force-pushed the 33294-eliminate-aspectmock-from-allure-helpertest branch from dee081d to 9484d85 Compare June 27, 2021 19:35
@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

@SilinMykola
Thank you for your pull request! We will review and update you soon.

@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

@jilu1
Copy link
Contributor

jilu1 commented Jun 30, 2021

@SilinMykola
Please fix the 3 unit test failures in this PR?

@sivaschenko
Copy link
Member

@SilinMykola thanks for the pull request! Would you be able to respond to the code review comments?

@SilinMykola
Copy link
Author

@sivaschenko hi! Yes, I'll try to fix all tests errors. I need some time for this.

@bohdan-harniuk bohdan-harniuk self-requested a review July 19, 2021 12:41
@bohdan-harniuk
Copy link
Contributor

Hello, @jilu1

I have a little bit helped for @SilinMykola with the aspect mock replacement here.
Please, proceed with the code review.

cc: @SilinMykola, @sivaschenko

@bohdan-harniuk bohdan-harniuk requested review from jilu1 and removed request for bohdan-harniuk and jilu1 July 20, 2021 08:55
@bohdan-harniuk bohdan-harniuk force-pushed the 33294-eliminate-aspectmock-from-allure-helpertest branch from d45efff to 804c7c2 Compare July 20, 2021 08:58
@bohdan-harniuk bohdan-harniuk force-pushed the 33294-eliminate-aspectmock-from-allure-helpertest branch from 804c7c2 to 1a71fe7 Compare July 20, 2021 09:04
andrewbess
andrewbess previously approved these changes Jul 20, 2021
Copy link
Contributor

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @SilinMykola @bohdan-harniuk
Thank you for your contribution.

@jilu1
Copy link
Contributor

jilu1 commented Jul 21, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

@bohdan-harniuk bohdan-harniuk added Partner: Atwix partners-contribution Pull Request is created by Magento Partner labels Jul 21, 2021
@bohdan-harniuk bohdan-harniuk self-requested a review July 21, 2021 14:53
);
}
return self::$instance;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This alternative way to instantiate an object of this class is only used for unit tests. This should not be used in MFTF. Am I understand it correctly here? If this is the case, can you make it clear in docblock?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jilu1, thank you for the suggestions. I've fixed it.

Copy link
Contributor

@jilu1 jilu1 Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bohdan-harniuk
Even with clear php doc, it's still confusing to add this static method in this class. Is there any other way?
The particular test is valuable, if this cannot be mocked by PHPUnit, can we turn this into a functional test https://github.com/magento/magento2-functional-testing-framework/tree/develop/dev/tests/functional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If copyFile() is the reason that prevents you from mocking the class, you could do something like:

private function copyFile($filePath, $outputPath)
{
    if (MftfApplicationConfig::getConfig()->getPhase() == MftfApplicationConfig::UNIT_TEST_PHASE) {
        return true;
    }
    return copy($filePath, $outputPath);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @jilu1 !
It is a great approach for the copyFile method! I will use it for the testAddAttachmentUniqueName testing method!
For other tested methods we have to mock AddUniqueAttachmentEvent with the singleton approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jilu1!
I've done that.
Thank you for your suggestion!

@bohdan-harniuk bohdan-harniuk removed their request for review July 21, 2021 14:59
Copy link
Contributor

@jilu1 jilu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bohdan-harniuk
Have you run this PR with magento platform-health branch? I have seen the following exception when running a build:

[group329] PHP Fatal error:  Uncaught TypeError: file_exists() expects parameter 1 to be a valid path, object given in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php:34
[group329] Stack trace:
[group329] #0 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php(34): file_exists()
[group329] #1 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Event/AddAttachmentEvent.php(34): Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent->getAttachmentFileName()
[group329] #2 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(116): Yandex\Allure\Adapter\Event\AddAttachmentEvent->process()
[group329] #3 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(92): Yandex\Allure\Adapter\Allure->processStepEvent()
[group329] #4 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/ in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php on line 34

This exception happened in multiple test groups.

@bohdan-harniuk
Copy link
Contributor

@bohdan-harniuk
Have you run this PR with magento platform-health branch? I have seen the following exception when running a build:

[group329] PHP Fatal error:  Uncaught TypeError: file_exists() expects parameter 1 to be a valid path, object given in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php:34
[group329] Stack trace:
[group329] #0 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php(34): file_exists()
[group329] #1 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Event/AddAttachmentEvent.php(34): Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent->getAttachmentFileName()
[group329] #2 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(116): Yandex\Allure\Adapter\Event\AddAttachmentEvent->process()
[group329] #3 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(92): Yandex\Allure\Adapter\Allure->processStepEvent()
[group329] #4 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/ in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php on line 34

This exception happened in multiple test groups.

Hello, @jilu1!
No, I haven’t checked it because we didn't change any business logic here:
Screenshot 2021-07-30 at 17 39 32

Could you please take a look at it? What do you think, how it is possible that we broke something?

Thanks, Bohdan

@jilu1
Copy link
Contributor

jilu1 commented Jul 30, 2021

@bohdan-harniuk
Have you run this PR with magento platform-health branch? I have seen the following exception when running a build:

[group329] PHP Fatal error:  Uncaught TypeError: file_exists() expects parameter 1 to be a valid path, object given in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php:34
[group329] Stack trace:
[group329] #0 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php(34): file_exists()
[group329] #1 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Event/AddAttachmentEvent.php(34): Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent->getAttachmentFileName()
[group329] #2 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(116): Yandex\Allure\Adapter\Event\AddAttachmentEvent->process()
[group329] #3 /var/www/html/vendor/allure-framework/allure-php-api/src/Yandex/Allure/Adapter/Allure.php(92): Yandex\Allure\Adapter\Allure->processStepEvent()
[group329] #4 /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/ in /var/www/html/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/Event/AddUniqueAttachmentEvent.php on line 34

This exception happened in multiple test groups.

Hello, @jilu1!
No, I haven’t checked it because we didn't change any business logic here:
Screenshot 2021-07-30 at 17 39 32

Could you please take a look at it? What do you think, how it is possible that we broke something?

Thanks, Bohdan
@bohdan-harniuk

I did not see anything obviously also but the failing build is observed when I run 5 PRs (#839, #843, #844, #845, #852) in a batch. Please double-check from your side. I will look into it more.

@jilu1
Copy link
Contributor

jilu1 commented Jul 30, 2021

@SilinMykola @bohdan-harniuk

FYI: The exception is reproducible running this PR branch alone.

…ing-framework into 33294-eliminate-aspectmock-from-allure-helpertest
@karyna-t
Copy link
Contributor

karyna-t commented Aug 4, 2021

Hi @jilu1 , I've just re-checked our PR. It seems that after the branch was actualized the problem that you described is gone. I don't see any errors on my local environment. Can you please check it one more time?

@jilu1
Copy link
Contributor

jilu1 commented Aug 4, 2021

Hi @jilu1 , I've just re-checked our PR. It seems that after the branch was actualized the problem that you described is gone. I don't see any errors on my local environment. Can you please check it one more time?

@karyna-tsymbal-atwix
Have you run this PR with Magento platform-health branch? To reproduce it, you can create a Magento PR based on platform-health and use mftf from this PR. You should see the problem when running the full CE/EE/B2B build. It happens in some test groups but not all of them.

@bohdan-harniuk
Copy link
Contributor

Hello, @jilu1 !

I've reproduced mentioned error! I'll fix it!

Thank you!

@bohdan-harniuk
Copy link
Contributor

bohdan-harniuk commented Aug 9, 2021

I've successfully reproduced mentioned issue:
Screenshot 2021-08-09 at 17 50 29

My steps to reproduce:

  1. Run any MFTF test without running WebDriver (ChromeDriver)
  2. Got this error

After fixing this issue I got the correct output:
Screenshot 2021-08-09 at 18 12 41

And successfully finished test:
Screenshot 2021-08-09 at 18 09 40

@jilu1, could you please recheck if everything is fine?

Thank you,
Bohdan.

bohdan-harniuk
bohdan-harniuk previously approved these changes Aug 9, 2021
@jilu1 jilu1 removed the needs update label Aug 9, 2021
@jilu1
Copy link
Contributor

jilu1 commented Aug 9, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 83e5cc0 into magento:develop Aug 11, 2021
@SilinMykola SilinMykola deleted the 33294-eliminate-aspectmock-from-allure-helpertest branch October 23, 2021 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Partner: Atwix partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants