Is it worth covering Magento 2 code by automated tests?

The implementation of automated tests has always been an interesting topic for many store owners and managers. We receive many questions every day like: should we invest money for tests in addition to development? How will it help an online business? Which tests are better and why? Therefore, we aim to shed some light on the most popular and useful types of tests and highlight the key reasons for their importance.

How-to-use-the-Magento-2-object-manager-in-your-unit-tests

Every unit test ninja faces troubles whenever he wants to test some real class functionality. Have you ever invoked toHtml() method of some block or beforeLoad() method of any collection? If you want to do it, you will need to mock a lot of classes that depend on other classes and so on. You would need to mock all of them, which would take a lot of time and effort. In a long run, you may blow up deadlines and it would really suck. Yes, you can try to change your testing strategy to avoid invoking such methods. But what if you still need to test them? Let’s explore how I addressed this issue.