I write a lot of integration tests for Magento 2. This helps my local development and they fit nicely in a CI way of working.
However, there are some oddities about the integration test suite of Magento. For example:
- It enables all modules by default, and there is no way to disable this. This can have some unwanted side-effects, because on a client project you most likely disable modules you don't need, for example, the Vertex module. However, this module adds a required field to your customer model, so needless to say, if you create a customer in your integration test, this test will fail.
- It adds Magento test modules to your codebase. So each time you ran your integration test suite, you end up with having 3 extra modules in your
app/code/Magentonamespace.
These issues make it hard for an integration test to be used in a local project. Someone once said to me that the integration tests are only created for extension developers to test if your module passes the criteria to make it to the marketplace. Is this true? Because if so: what's then to a proper way to write integration tests for your clients' webshop? I do like the Magento annotations and stuff. Really frustrating this.
1 Answer 1
I feel you, I have / had the same issues. There is a solution for your first problem: Remove the unwanted modules instead of just disabling them. Add the following to your composer.json:
"replace": {
"magento/module-admin-notification": "*"
},
if you want to remove the admin notification module for example. It's fully explained in my blog post at https://www.integer-net.com/removing-unused-core-modules-from-magento-2-the-right-way.
Regarding your second point: it's a bug, filed at https://github.com/magento/magento2/issues/12696. I find it really annoying too. There is no good solution for that yet as far as I know, except commenting on the bug report and thus bringing it to attendance of the core developers.
Someone once said to me that the integration tests are only created for extension developers to test if your module passes the criteria to make it to the marketplace. Is this true?
No. It's also really useful on a project base. You just have to take care of the issues you mentioned.