Modal Title
DevOps Tools / Observability / Software Development

Why Test Debugging Is Crucial for the Retail Sector

A look at effective testing strategies for retail and how test observability and debugging can result in higher return on investment from tests.
Jan 10th, 2023 12:00pm by
Featued image for: Why Test Debugging Is Crucial for the Retail Sector
Feature image via Pixabay

To thrive in today’s competitive market, retail companies need a quality application that keeps pace with customers’ buying habits in the digital-first economy. The contemporary consumer is tech savvy and expects a seamless customer experience — from finding the product they want to paying for the goods.

A Digital Commerce 360 study found that in 2020, the top 500 retail companies generated $849.5 billion in online sales, a 45.3% increase over the previous year — the biggest jump ever recorded. Yet even if the product is unparalleled, a poor customer experience can cost retailers sales. It’s been reported that 25% of customers take their business elsewhere because of poor in-store shopping experiences.

In retail apps, however, can face a number of issues, many of which can be avoided:

  • Performance bottlenecks, including failure to perform as expected under varying loads, may cause downtime or render the app unusable during peak periods.
  • Security issues can result due to a failure to ensure that customer data is stored, copied and transmitted securely.
  • Issues or intermittent failure can be caused by third-party integrations, such as payment providers.
  • Functional issues may include bugs in the code, issues of compatibility on different platforms or lack of support for older browsers.

Testing that all features in a retail app are properly integrated and work as expected is one of the most efficient ways to uncover bugs that can jeopardize user experience. In this post, we’ll look at effective testing strategies for retail and how test observability and debugging can result in higher return on investment (ROI) from tests.

Why Testing Is Crucial to Retail

With the growth of e-commerce and the migration of businesses online, a high-quality digital experience is critical and requires the right testing strategy. Testing is crucial to retail for a number of reasons, which we will explore below.

Agility

Testing provides the agility that developers need to detect problems rapidly and adapt their existing codebase. Automated tests provide the quick feedback loop that engineers require to stay productive. Thanks to continuous integration (CI) pipelines, engineers don’t have to do anything other than react when a test fails.

Security

Customers have become hesitant to disclose their personal information. However, retail apps require this data to deliver personalized recommendations and assist customers in purchasing decisions. Application security testing helps to identify flaws and loopholes in software code that could otherwise be exploited by attackers.

Quality

In automated tests, coverage includes both new features and existing features from earlier iterations. This ensures that old software features continue to function as intended despite changes. Because automated tests can be run several times without human intervention, they maintain code quality and assist retailers in providing a bug-free experience to end users.

Confidence and Predictability

Automated tests validate that a specific feature only does what it’s intended to do. This ensures consistent results and uniformity in what is being tested. It also helps your engineers gain confidence in their codebases.

Demonstrating Sample Retail Applications

In our sample e-commerce web application, users can buy goods with Stripe or PayPal payment support. Users must sign in before they can make a purchase. Registering for a new account requires providing a username and password. Users are able to view all available products on the home page.

Figure 1: Home page showing all the available products

Users can add products to their cart and purchase them using Stripe.

Demonstrating the Tests for the Application

We need to write some tests to make sure our application works as expected. Below are the tests to check the default value of the object models for “Item” and “OrderItem”:


Basically, these tests just check to make sure the default values for “Item” and “OrderItem” instances must be 1.

Integrate the GitHub Workflow with Foresight

Let’s create a GitHub workflow file with Foresight integrated. This will allow us to monitor workflows and debugging tests in the future, without having to scroll through an ocean of logs in the GitHub Action pages.

We have set up this workflow to trigger a GitHub Action for every pull request on the main branch. We added steps for workflow telemetry and the Foresight test kit, so Foresight can collect workflow and test metrics. For a detailed explanation, see how workflow telemetry and the Foresight test kit action work.

Production Bug in the Retail Application

Let’s say after your team releases a new feature to production, and the customer service team gets a lot of complaints. Customers complain that they are forced to buy seven items of every product, and they can’t buy fewer. The CTO wants this bug fixed immediately since it directly affects customers’ buying processes, and there has already been a noticeable decrease in purchases.

Figure 2: The problem customers face when adding new products

Fixing the Bug with the Help of Foresight

Figure 3: Latest workflow is failed viewing from Foresight

Let’s go to the Foresight dashboard to see if there is any issue with the latest build of the application.

The run of the latest workflow has failed.

By looking at details of the recent workflows, we can see that the step for executing tests has failed.

Figure 4: The workflow failed because of a failure in the tests’ execution step

Click on the “Tests” tab to see the recent code changes and the tests’ status.

Figure 5: Change impact analysis from Foresight captures the recent changes in the code

We saw that there are two of the 46 lines that were not tested, and one of the tests failed. Let’s take a closer look at the failed test.

Figure 6: Validation failed in the test for checking the default value of “OrderItem”

Here we see the test failed due to the mismatched value between the expected default quantity and the real default quantity. The development team was already aware of this when they ran this in a local test, but they thought it was just a flaky test due to the environment setup, and let it slip.

After looking at the code changes, we noticed something strange.

Figure 7: Code changes in the “OrderItem” for default value is now set to 7

In the “core/models.py” file, the default value of the quantity is accidentally set to 7, which is the reason the test failed for the default value of “OrderItem,” and also explains why the default number of items is set to 7 when customers buy the new product.

We can fix this bug by changing the default value for the “OrderItem” model to 1. After deploying this change to the production environment, we notice the workflow has now passed.

Figure 8: After the fix, the workflow has now passed

Now that the issue has been fixed, the customers can buy as few as one item.

Streamline Monitoring and Debugging

Foresight makes monitoring and debugging workflows a breeze with features such as workflow highlights, workflow metrics, code capture changes and details for every step in the testing process. Sign up for Foresight here.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Pragma.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.