Skip to content

MQE-1962: Remove support of deprecated locations for tests #595

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

Merged
merged 7 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento2-functional-testing-framework",
"description": "Magento2 Functional Testing Framework",
"type": "library",
"version": "2.6.3",
"version": "3.0.0",
"license": "AGPL-3.0",
"keywords": ["magento", "automation", "functional", "testing"],
"config": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,6 @@ function ($arg) {
'Test' . DIRECTORY_SEPARATOR .'Mftf'
]
);
$mockResolver->verifyInvoked(
'globRelevantPaths',
[
$magentoBaseCodePath
. DIRECTORY_SEPARATOR . "dev"
. DIRECTORY_SEPARATOR . "tests"
. DIRECTORY_SEPARATOR . "acceptance"
. DIRECTORY_SEPARATOR . "tests"
. DIRECTORY_SEPARATOR . "functional"
. DIRECTORY_SEPARATOR . "Magento"
. DIRECTORY_SEPARATOR . "FunctionalTest"
, ''
]
);
}

/**
Expand Down
58 changes: 58 additions & 0 deletions docs/mftf-tests-packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<style>
.mftf-dl {
margin-bottom: 2.5em;
}
dl dt{
font-weight:400;
}
</style>

# MFTF functional test modules and packaging

## MFTF predefined test module paths
The Magento Functional Testing Framework can run tests from predefined paths and custom paths. The predefined paths are:
```
app/code/<Vendor>/<Module>/Test/Mftf
dev/tests/acceptance/tests/functional/<Vendor>/<TestModule>
vendor/<Vendor>/<Module>/Test/Mftf
vendor/<Vendor>/<TestModule>
```

To support future service isolation, Test module in `dev/tests/acceptance/tests/functional/<Vendor>/<TestModule>` and
`vendor/<Vendor>/<TestModule>` must define the module type as `magento2-functional-test-module` in its `composer.json` file.
No `composer.json` file is required for tests in `app/code/<Vendor>/<Module>/Test/Mftf` and `vendor/<Vendor>/<Module>/Test/Mftf`
as they are part of the Magento modules.

Test module for a specific Magento module can only be in one of the paths.

## Test module composer.json format

Test module `composer.json` file should use type `magento2-functional-test-module`.

Test module `composer.json` file should define Magento module dependencies in suggests block.
MFTF will recognize the dependency if the suggest message of a module specifies `type` using `magento2-module` and `name`
using module name registered with Magento.

Here is an example `composer.json` file for the test module `dev/tests/acceptance/tests/functional/Magento/ConfigurableProductCatalogSearch`:

```json
{
"name": "magento/module-configurable-product-catalog-search-functional-test",
"description": "MFTF test module for Magento_ConfigurableProduct and Magento_CatalogSearch",
"type": "magento2-functional-test-module",
"config": {
"sort-packages": true
},
"require": {
"magento/magento2-functional-testing-framework": ">=2.5"
},
"suggest": {
"magento/module-configurable-product": "type: magento2-module, name: Magento_ConfigurableProduct, version: *",
"magento/module-catalog-search": "type: magento2-module, name: Magento_CatalogSearch, version: *"
},
"license": [
"OSL-3.0",
"AFL-3.0"
]
}
```
25 changes: 1 addition & 24 deletions src/Magento/FunctionalTestingFramework/Util/ModuleResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ class ModuleResolver
. 'tests'
. DIRECTORY_SEPARATOR
. 'functional';
const DEPRECATED_DEV_TESTS = DIRECTORY_SEPARATOR
. self:: DEV_TESTS
. DIRECTORY_SEPARATOR
. "Magento"
. DIRECTORY_SEPARATOR
. "FunctionalTest";

/**
* Enabled modules.
Expand Down Expand Up @@ -327,8 +321,7 @@ private function aggregateTestModulePaths()
$codePathsToPattern = [
$modulePath => '',
$magentoBaseCodePath . $vendorCodePath => self::TEST_MFTF_PATTERN,
$magentoBaseCodePath . $appCodePath => self::TEST_MFTF_PATTERN,
$magentoBaseCodePath . self::DEPRECATED_DEV_TESTS => ''
$magentoBaseCodePath . $appCodePath => self::TEST_MFTF_PATTERN
];

foreach ($codePathsToPattern as $codePath => $pattern) {
Expand Down Expand Up @@ -374,22 +367,6 @@ private function globRelevantPaths($testPath, $pattern)
}
}

/* TODO uncomment this to show deprecation warning when we ready to fully deliver test packaging feature
if (strpos($testPath, self::DEPRECATED_DEV_TESTS) !== false && !empty($modulePaths)) {
$deprecatedPath = ltrim(self::DEPRECATED_DEV_TESTS, DIRECTORY_SEPARATOR);
$suggestedPath = self::DEV_TESTS . DIRECTORY_SEPARATOR . 'Magento';
$message = "DEPRECATION: Found MFTF test modules in the deprecated path: $deprecatedPath."
. " Move these test modules to $suggestedPath.";

if (MftfApplicationConfig::getConfig()->verboseEnabled()) {
LoggingUtil::getInstance()->getLogger(ModuleResolver::class)->warning($message);
}
// Suppress print during unit testing
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
print ("\n$message\n\n");
}
}
*/
return $modulePaths;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Magento/FunctionalTestingFramework/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
// define TEST_PATH and TEST_MODULE_PATH
defined('TESTS_BP') || define('TESTS_BP', realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'dev/tests/acceptance'));

$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/Magento/FunctionalTest';
$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/Magento';
defined('TESTS_MODULE_PATH') || define(
'TESTS_MODULE_PATH',
realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH)
Expand Down