Vinai Kopp

Magento Expert, Developer & Trainer

  • Why I promoting testing

    April 15, 2016

    The move from M1 to M2

    Since February 2015 more and more of my work has been about Magento 2. It includes (amongst others) thousands of unit and functional tests.

    My expectation was that many extension developers and integrators would immediately start picking up automated testing, too.
    The move to Magento 2 forced developers to part with old habits anyway, and while learning to work with the new platform, I hoped they would invest into learning testing skills, too.

    Forward to some day mid-January 2016. The first Magento 2 extensions where being released, and I realized it wasn’t happening on it’s own.
    Many of the extensions didn’t include any tests at all. Of course there are exceptions, however it seemed as if “no tests” still was the norm.

    It looked as if the chance to raise the overall quality of Magento implementations in our ecosystem was passing.

    My goal

    The purpose of the Mage2Katas project is raise the quality of Magento 2 related code.
    This will result in developers having an easier life, more successful projects and more satisfied merchants.

    It will be simple to work with an inherited project. New customizations or changes to existing features can be made quickly and deployed with confidence.

    My motivation

    I must admit, I’m not making Mage2Katas for selfless reasons. Professionally I have heavily invested into Magento.

    However, I believe that if the Magento ecosystem thrives, it is good for all of us.
    I will do well and so will all the other thousands of people who earn their living with Magento.

    I enjoy working with the Magento products, both as a developer and while training other developers.

    The past

    There have been many successful projects, but to be honest, not all went well.
    And even with the successful ones, there often was an amount of maintenance and effort associated with them that I couldn’t help asking myself “Isn’t there a better way?”.

    When I discovered automated testing back in 2011 it was a revelation. It solved so many issues.
    Maintainability and quick update cycles became the norm. Instead of fighting with the same bugs again and again, real progress happened.
    This applied to both, Magento 1.x projects and non-Magento related development.

    Tools such as TDD and integration tests are an established part of our industry. By not using them we are damaging ourselves.

    How to get started

    One of the stoppers for most developers is missing time to aquire the skills.
    It is true that adopting testing practice (both TDD and integration tests) will slow down development at first.
    From my experience productivity takes a hit for 1-3 months. Then things change.

    Currently I write about twice as much testing code as production code, but still I am faster then before I started using TDD over the course of a project.

    During the previous 2 weeks the Magento 2 devdocs team was so kind to merge two PRs from me describing the steps to execute the unit tests and the integration tests that are included with Magento 2.
    It includes instructions on how to prepare the integration test environment.

    I’ve also written an article on what to keep in mind when writing testable code. I’m not very satisfied with the result, but doing that right would fill books. And those books already have been written.

    But it is not necessary to read all the books and look at all the tutorials before getting started.

    As with everything new, all that is required is the willingness to break with old habits, try things and to make mistakes.

    Just start, and over time a sense of how and what to test will grow. Read and watch to learn, but the main thing is doing.

    comments powered by Disqus