Detect and fix — a Magento testing suite for bug-free sales

Just as a space rocket undergoes a thorough check-up before the launch, a Magento web store needs to be tested from A to Z routinely. Of course, after-effects of the rocket malfunctioning somewhere in orbit come at a much higher cost (literally and figuratively), but in their ecommerce space, merchants also don’t want to lose customers (read profit) due to website bugs.

Luckily, Magento 2 is equipped with a full-fledged testing suite to audit each component of a web store. Poor code and flawed interactive features, conflicting extensions and crashed APIs — the earlier merchants detect bugs, the fewer negative effects on the store performance they will experience. Come and join us on a tour around default Magento 2 testing types to know when and why you need each of them. For better understanding and an element of fun, we will draw a parallel with a brick-and-mortar store (where possible) to see how Magento testing could be applied there.

Magento testing

Magento testing suite

Merchants who run Magento-based web stores must be aware of 6 major types of tests:

1. Functional testing

Functional tests simulate customer behavior on an ecommerce website and check if everything works flawlessly on the frontend. Test steps interact directly with page objects and trigger possible actions such as clicking Home or getting guest order ID.

Magento Functional Testing Framework allows running various types of tests (basic acceptance testing, smoke testing, regression testing, etc.). The three elements required for functional testing are PHPUnit (download here), Selenium Standalone Server (download here) and a web browser. To succeed in testing, don’t overlook the following points:

  • Specify the URLs to Magento front- and backend in PHPUnit first. Then you can update additional parameters.
  • Depending on the browser you use, make sure that it has WebDriver for Selenium.
  • Specify credentials to external services (like PayPal or DHL) if you use any.

This type of Magento tests can be useful at each stage of a Magento store lifecycle. Once a store is configured, merchants need to check the overall performance before the launch. If developers change or add some functionality later, testing ensures the changes don’t interfere with the daily operation of the store. Also, periodic regression testing should become a part of Magento maintenance activities.

Let’s now move to a brick-and-mortar store to see what would be the counterpart of functional testing there. As it is intended first and foremost to provide a seamless customer journey across the store, testers would need to act as customers and check if they can easily reach products, see all price labels and, generally speaking, make sure that nothing hinders the shopping process.

2. Static testing

Static tests analyze the code without running it. Their primary purpose is to check if PHP and JavaScript code corresponds to Magento 2 coding standards and best practices. When merchants extend the functionality of their Magento-based web store, they initiate static tests to detect code quality issues as early as possible not to get them mounted later. 

Static testing in Magento contains quite a number of tests to ensure the code stability and quality. Along with simple standard tests for JavaScript and PHP, more complicated integrity tests target complex scenarios like circular dependency or exception hierarchy. In order to check for obsolete references, Magento developers have legacy tests at hand. They are a must measure after the web store upgrade.

In a brick-and-mortar store, static testing would be similar to building commissioning. If store owners don’t check its compliance with established quality standards and paint uneven walls, they would have this defect crashing visual impression for customers.

3. Integration testing

To get the most out of their web store, merchants may need to integrate Magento with third-party systems like CRM, ERP or PIM. Integration testing comes to help to ensure seamless interaction between them. It checks if data flows between store parts correctly and any updates get reflected in all the systems involved.

For example, a customer is placing an order. Functional testing checks possible scenarios of successful and unsuccessful payments from a customer’s perspective. Meanwhile, integration testing shows if the order gets added to a customer’s CRM account to make sure data synchronization functions well.   

This kind of tests requires a separate integration test database. Otherwise, one risks having pieces of data (products, orders, customers, etc.) lost. Also, a dedicated database user who will run the tests is not recommended to have access to other databases for security reasons.

In Magento, integration testing targets to achieve well-coordinated work of all third-party business systems. In a physical store, testers would need to check how goods are supplied, stored and merchandized, thus ensuring the efficiency of the supply chain and retail operations.

4. Unit testing

While conducting unit testing, developers focus on a single unit of PHP code to check a particular function or module. For example, Magento developers have customized the checkout page and launched it untested. In the worst-case scenario, customers may run into issues while completing the purchase and abandon the process. To prevent this, we recommend testing each unit of the code during the development stage. 

Unit testing in Magento is similar to inspecting separate internal systems of a brick-and-mortar store. Thus, one doesn’t need to perform a full inspection of the building to check if the fire safety system, electricity, plumbing and other systems run smoothly.

5. Web API functional testing

Being invisible for customers, multiple Web APIs on ecommerce websites act as connectors to third-party servers. For example, they help in social media marketing. As merchants want to reach more customers in social networks, they start business accounts on popular platforms like Instagram, Snapchat or Pinterest and may want to stream news feeds to the store. In this case, social Web APIs connect directly to the accounts and synchronize the updates. Or payment gateway APIs create a virtual bridge between the checkout page and a payment acquiring network. Thus, customers complete the payment without leaving the website

The purpose of Web API functional testing is to check the operation of Magento Web APIs and reveal any deviations from the expected performance. Magento 2 supports both web service communication protocols – REST (Representational State Transfer) and SOAP (Simple Object Access Protocol).

As far as we have mentioned payment process in connection with Web API functional testing in Magento, let’s draw the same parallel to a brick-and-mortar store. Knowing how irritating delays in customer service can be, retailers need to ensure that their POS-terminals connect to banks successfully and customers don’t have to line up waiting for failures to be fixed.

6. JavaScript testing

One of the three pillars of web development, JavaScript is responsible for creating dynamic and interactive experience for users. As a rule, much of the functionality on ecommerce websites is JavaScript-powered including dropdown lists, videos, animated page elements like resizing or relocating and more. Aiming at enhancing customer experience, these features can have precisely the opposite effect if crash. Having stumbled upon a single malfunction, customers will naturally question the website quality on the whole. Meanwhile, customer trust is one of the foundations for their loyalty.

Targeted testing ensures that all JavaScript elements in a Magento-based web store function as expected. Out of the box, Magento offers to combine the power of Jasmine’s clean syntax and JsTestDriver’s test runner, thus allowing a fast and effective way to check the accuracy of JavaScript functions.

Final thoughts

Magento is an open-source ecommerce platform so the out-of-the-box functionality rarely (most likely never) meets the needs of online retailers. As they customize it to their business, they must ensure the changes don’t go against them. By including Magento testing in their regular routine, sellers defend themselves against bugs showing up and spoiling customer experience. We hope that our overview of Magento 2 testing suite has identified critical areas to check in a web store in order to enjoy its flawless performance.

We will not leave you alone with Magento issues. Out team will stand behind your online store and ensure its failure-free operation.

About the Author: Tanya Yablonskaya

Tanya is Ecommerce Industry Analyst at ScienceSoft, an IT consulting and software development company headquartered in McKinney, Texas. After 2+ years of exploring the cryptocurrency and blockchain sphere, she has shifted the focus of interest to ecommerce industry. Delving into this enormous world, Tanya covers key challenges online retailers face and unveils a wealth of tools they can use to outpace competitors.