|
| 1 | +#Git vs Composer Installation of Magento with MFTF |
| 2 | + |
| 3 | + |
| 4 | +###How to download Magento + MFTF from GitHub? |
| 5 | + |
| 6 | +If you are planning on contributing a PR to the Magento 2 codebase, you can download Magento 2 from GitHub. Contribution to the codebase is done using the 'fork and pull' model where contributors maintain their own fork of the repo. This repo is then used to submit a pull request to the base repo. |
| 7 | + |
| 8 | +Install guide: [GitHub Installation](https://devdocs.magento.com/mftf/docs/getting-started.html) |
| 9 | + |
| 10 | +###How to download Magento + MFTF via Composer? |
| 11 | + |
| 12 | +Composer install downloads released packages of Magento 2 from the composer repo [https://repo.magento.com](https://repo.magento.com). |
| 13 | + |
| 14 | +All Magento modules and their MFTF tests are put under `<vendor>` directory for convenience of 3rd party developers. With this setup, you can keep your custom modules separate from the core. You can also develop modules in a separate VCS repository and add them to your `composer.json` which will allow them to be installed into the `vendor` directory. |
| 15 | + |
| 16 | +Install guide: [Composer based Installation](https://devdocs.magento.com/guides/v2.3/install-gde/composer.html) |
| 17 | + |
| 18 | + |
| 19 | +###Managing MFTF test artifacts - Composer vs GitHub |
| 20 | + |
| 21 | +####Via GitHub: |
| 22 | + |
| 23 | +Cloning Magento 2 git repository is a way of installing when you don't have to worry frequently about matching the codebase with production. Your version control system generally holds and manages your `app/code` folder and you can do manual ad-hoc development here. |
| 24 | + |
| 25 | +####Via composer: |
| 26 | + |
| 27 | +Magento 2 advocates the use of composer for managing modules. When you install a module through composer, it is added to `vendor/<vendor-name>/<module>` |
| 28 | + |
| 29 | +If you are developing your own module or adding MFTF tests to the module, you should not edit `vendor` because a composer update could clobber your changes. Instead, you can override a module under `vendor`, by adding files or cloning your module specific git repo to `app/code/<vendor-name>/<module>`. |
| 30 | + |
| 31 | +If you want to distribute the module and its tests, you can initialize a git repo and create a [composer package](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/package/package_module.html). In this way others will be able to download and install your module and access your tests as a composer package, in their `<vendor>` folder. |
| 32 | + |
| 33 | + |
| 34 | +###MFTF test artifacts location |
| 35 | + |
| 36 | +- For GitHub installation, MFTF test artifacts are located at `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/`. This is the directory to create new tests or maintain existing ones. |
| 37 | + |
| 38 | +- For Composer based installation, MFTF test artifacts are located at `<magento_root>/vendor/<vendor_name>/<module_name>/Test/Mftf/`. This is the directory to run tests fetched by Composer. |
| 39 | + |
| 40 | +The file structure under both paths is the same as below: |
| 41 | + |
| 42 | +```tree |
| 43 | +<Path> |
| 44 | +├── ActionGroup |
| 45 | +│ └── ... |
| 46 | +├── Data |
| 47 | +│ └── ... |
| 48 | +├── Metadata |
| 49 | +│ └── ... |
| 50 | +├── Page |
| 51 | +│ └── ... |
| 52 | +├── Section |
| 53 | +│ └── ... |
| 54 | +└── Test |
| 55 | + └── ... |
| 56 | +``` |
| 57 | + |
| 58 | +###How ModuleResolver reads modules |
| 59 | + |
| 60 | +In either of the installations, all tests and test data are read and merged by MFTF's ModuleResolver in the order indicated the below: |
| 61 | + |
| 62 | +1. `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/` |
| 63 | +2. `<magento_root>/vendor/<vendor_name>/<module_name>/Test/Mftf/` |
| 64 | + |
| 65 | +###Conclusion |
| 66 | + |
| 67 | +There are no differences from MFTF's perspective between having the test artifacts in `app/code` or in `/vendor` as it reads artifacts from both paths. It works the same. Composer based install may benefit teams when there's a need to match file systems in dev and production. |
| 68 | + |
| 69 | +If you are a contributing developer with an understanding of Git and Composer commands, you can choose the GitHub installation method instead. |
| 70 | + |
| 71 | + |
| 72 | + |
0 commit comments