-
Notifications
You must be signed in to change notification settings - Fork 132
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
33294 eliminate aspectmock from allureHelperTest #839
Conversation
dee081d
to
9484d85
Compare
@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework |
@SilinMykola |
@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework |
@SilinMykola |
@SilinMykola thanks for the pull request! Would you be able to respond to the code review comments? |
@sivaschenko hi! Yes, I'll try to fix all tests errors. I need some time for this. |
Hello, @jilu1 I have a little bit helped for @SilinMykola with the aspect mock replacement here. cc: @SilinMykola, @sivaschenko |
d45efff
to
804c7c2
Compare
804c7c2
to
1a71fe7
Compare
There was a problem hiding this 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.
@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework |
@jilu1 the pull request successfully imported. |
); | ||
} | ||
return self::$instance; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this 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.
Hello, @jilu1! Could you please take a look at it? What do you think, how it is possible that we broke something? Thanks, Bohdan |
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. |
FYI: The exception is reproducible running this PR branch alone. |
…ing-framework into 33294-eliminate-aspectmock-from-allure-helpertest
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 |
Hello, @jilu1 ! I've reproduced mentioned error! I'll fix it! Thank you! |
…ing-framework into 33294-eliminate-aspectmock-from-allure-helpertest
I've successfully reproduced mentioned issue: My steps to reproduce:
After fixing this issue I got the correct output: And successfully finished test: @jilu1, could you please recheck if everything is fine? Thank you, |
@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework |
@jilu1 the pull request successfully imported. |
0641788
Description
Eliminate AspectMock usage from
dev/tests/unit/Magento/FunctionalTestFramework/Allure/AllureHelperTest.php
Fixed Issues
Contribution checklist