magento / magento2-functional-testing-framework

Magento2 Functional Testing Framework
Other
155 stars 133 forks source link

33308: Eliminated AspectMock usage from ModuleResolverTest.php #852

Closed anzin closed 3 years ago

anzin commented 3 years ago

Description

I've eliminated AspectMock usage from dev/tests/unit/Magento/FunctionalTestFramework/Util/ModuleResolverTest.php

Fixed Issues (if relevant)

  1. Fixes magento/magento2#33308: [MFTF] Eliminate AspectMock from ModuleResolverTest (Complex!)

Contribution checklist

jilu1 commented 3 years ago

@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework

magento-engcom-team commented 3 years ago

@jilu1 the pull request successfully imported.

jilu1 commented 3 years ago

@anzin Thank you for your PR! Please address unit test failure in ModuleResolverTest.

jilu1 commented 3 years ago

@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework

magento-engcom-team commented 3 years ago

@jilu1 the pull request successfully imported.

anzin commented 3 years ago

Hello @jilu1 , sorry I don't understand your question. I removed these tests because we eliminate AspectMock, and these tests are not necessary, or I misunderstood something?

Thank you.

jilu1 commented 3 years ago

Hello @jilu1 , sorry I don't understand your question. I removed these tests because we eliminate AspectMock, and these tests are not necessary, or I misunderstood something?

Thank you.

@anzin Can you explain why these tests are not necessary? In other words, should you add these testAggregateTestModulePathsDevTests, testGetModulePathsLocations, testGetComposerJsonTestModulePathsForPathInvocation, testGetComposerInstalledTestModulePathsForPathInvocation as unit test for new class ModuleResolverService?

anzin commented 3 years ago

ModuleResolverService

Hello, @jilu1!

Yes, I will try to add them!

Thank you!

anzin commented 3 years ago

Hello @jilu1 , sorry I don't understand your question. I removed these tests because we eliminate AspectMock, and these tests are not necessary, or I misunderstood something? Thank you.

@anzin Can you explain why these tests are not necessary? In other words, should you add these testAggregateTestModulePathsDevTests, testGetModulePathsLocations, testGetComposerJsonTestModulePathsForPathInvocation, testGetComposerInstalledTestModulePathsForPathInvocation as unit test for new class ModuleResolverService?

@jilu1, ~could you please help me to understand what does that test do? -> testAggregateTestModulePathsDevTests... because of the same reason.~

I've found what exactly those tests do! I'll rewrite them without using AspectMock!

Thanks!

anzin commented 3 years ago

Hello, @jilu1, I've added new PR where returned deleted tests and fixed them so that they do not use AspectMock, please check if everything is well.

Thanks.

anzin commented 3 years ago

Hello @jilu1, my idea was to mock these methods because one test is did not passed, but then it turned out that it is not necessary to do so I put everything back.

Thanks.

jilu1 commented 3 years ago

@anzin

I understand why you moved some methods back. But my above question is actually why you keep wrapper methods like:

    private function getComposerInstalledTestModulePaths($composerFile)
    {
        return ModuleResolverService::getInstance()->getComposerInstalledTestModulePaths($composerFile);
    }

    private function getCustomModulePaths()
    {
        return ModuleResolverService::getInstance()->getCustomModulePaths();
    }

while you can call ModuleResolverService::getInstance()->getComposerInstalledTestModulePaths($composerFile); or ModuleResolverService::getInstance()->getCustomModulePaths(); directly. Is it to help with unit test?

anzin commented 3 years ago

@jilu1 , I understood what you mean, I've corrected the code please check if everything is well.

Thanks for your review.

anzin commented 3 years ago

Hello @jilu1 , I've fixed test 'testGetModulePathsLocations', please check if everything is well.

Thanks.

jilu1 commented 3 years ago

@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework

magento-engcom-team commented 3 years ago

@jilu1 the pull request successfully imported.