Turn your manual testers into automation experts Request a DemoStart testRigor Free

PrestaShop Testing

PrestaShop Testing

PrestaShop is a free, open-source e-commerce platform that enables businesses to create and manage their online stores. Launched in 2007, it has become one of the most popular e-commerce solutions globally due to its user-friendly interface, extensive customization options, and a wide range of features.

PrestaShop is built on the PHP programming language and uses MySQL for database management. It offers a variety of built-in features, such as product and inventory management, payment gateway integrations, multi-language and multi-currency support, marketing tools, and order management. Additionally, its modular architecture allows users to extend its functionality with plugins and themes available from the PrestaShop marketplace.

In this framework, you have the capability to customize the following:

A default set of themes and modules are made available to you as a part of the original project. However, you can apply further customizations to make sure that your website grows and behaves the way you want it to. Prestashop also allows you to host your website easily.

As per the testing pyramid, here’s the most popular way to structure your testing efforts for a PrestaShop application:

Unit Testing

Unit testing involves testing individual units or components of a software application. A unit is typically the smallest testable part of the code, such as a function or method. The primary purpose of unit testing is to validate that each unit of the software performs as expected. By breaking down the application into small, manageable units, developers can identify and fix issues early in the development process. This helps improve the overall quality and reliability of the software.

PrestaShop supports the PHPUnit framework. It is essential to have a clean folder structure. In Prestashop, the unit test case should be located in the tests/Unit folder and have the same path as the tested class. For example, if the class to be tested is in src/Core/Foo/Baz, then the unit test should be in the tests/Unit/Core/Foo/Baz folder.

Using the TestCase class to base your unit tests on is advisable. It will look something like this.
<?php
  namespace Tests\Unit\Foo;
  
  use PHPUnit\Framework\TestCase;
  
  class BarTest extends TestCase
  {
    /* ... */
  }
Unit tests can look something like this.
<?php
use PHPUnit\Framework\TestCase;

class EqualsTest extends TestCase
{
  public function testFailure()
  {
    $this->assertEquals(1, 0);
  }

  public function testFailure2()
  {
    $this->assertEquals('bar', 'baz');
  }
}
?>
The above example is a basic depiction of using assert methods to validate results. Below is another example of a unit test.
<?php
use PHPUnit\Framework\TestCase;
class DependTest extends TestCase
{
  public function testEmpty()
  {
    $value = [];
    $this->assertEmpty($value);
    return $value;
  }

  /**
   * @depends testEmpty
  */

  public function testPush(array $value)
  {
    array_push($value, 'first');
    $this->assertEquals('first', $value[count($value) - 1]);
    $this->assertNotEmpty($value);
    return $value;
  }
}
?>

Integration Testing

The next step after testing different units in your code in isolation is to see if they also work together well. This is where integration testing comes into the picture. You can plan your test cases such that the integrations at crucial junctions are tested.

For example, if your e-commerce website is to call a third-party payment gateway, then you can have positive and negative integration tests revolving around this scenario. Other areas that you can target for integration testing could be places where there are integrations with databases, file management systems, and any third-party applications.

Below are a couple of integration test case examples.
<?php
namespace Tests\Integration;
use Tests\TestCase;

class MathTest extends TestCase
{
  public function setUp()
  {
    parent::setUp();
    $this->math = $this->app->make('App\Math');
  }

  public function test_getArea_WhenCalledWithLength2_Return4()
  {
    $response = $this->math->getArea(2);
    $this->assertTrue(is_int($response));
    $this->assertEquals(4, $response);
  }
}
<?php
 function testSavingUser()
 {
  $user = new User();
  $user->setName(Erica);
  $user->setSurname(Jones);
  $user->save();
  $this->assertEquals(Erica Jones, $user->getFullName());
  $this->tester->seeInDatabase('users', ['name' => Erica, 'surname' => Jones]);
 }

End-to-End Testing

End-to-end or system testing verifies the behavior and performance of an application from start to finish, covering the entire system flow or business process. This type of testing is also known as "black-box testing," as it focuses on the functionality of the application without requiring knowledge of the internal workings of the system.

The goal of end-to-end testing is to simulate real-world scenarios and identify any issues or defects that may arise when actual users use the application. It typically involves testing the application as a whole, including its interfaces with external systems, databases, and other dependencies.

You can do that using the following ways.
  • UI testing with supported tools
  • Selenium-based tools
  • testRigor

UI testing with supported tools: Playwright, Mocha, Chai, Faker

Prestashop offers support to automate UI scenarios with the help of the following tools. It uses
  • Playwright as the automation tool
  • Mocha as the testing framework
  • Chai as the assertion library
  • Faker as the mock data generator
Below is an example of using Playwright to manage browser manipulations, Mocha to define the test framework, and Chai for performing the assertions. The test case below checks if the to-do list loaded is empty and whether a new item gets added to the list.
const playwright = require('playwright')
const chai = require('chai')
const expect = chai.expect
const BASE_URL = 'http://todomvc.com/examples/react/#/'

// playwright variables
let page, browser, context

describe('TO DO APP TESTS - PLAYWRIGHT', () => {
  beforeEach(async () => {
    browser = await playwright['chromium'].launch({ headless: false })
    context = await browser.newContext()
    page = await context.newPage(BASE_URL)
  })
  
  afterEach(async function() {
    await page.screenshot({ path: `${this.currentTest.title.replace(/\s+/g, '_')}.png` })
    await browser.close()
  })

  it('List is loaded empty', async() => {
    const sel = 'ul.todo-list li'
    const list = await page.$$(sel)
    expect(list.length).to.equal(0)
  })

  it('Adds a new todo in empty list', async() => {
    await page.waitForSelector('input')
    const element = await page.$('input')
    await element.type('Practice microsoft playwright')
    await element.press('Enter')

    // check list of ToDo
    const sel = 'ul.todo-list li'
    await page.waitForSelector(sel)
    const list = await page.$$(sel)
    expect(list.length).to.equal(1)
    expect(await page.$eval(sel, node => node.innerText)).to.be.equal('Practice microsoft playwright')
  })
})

testRigor for end-to-end testing

testRigor is one of the easiest ways to cover your entire application with robust end-to-end tests. Why? Because it's a no-code AI-driven tool and solves a lot of the tricky aspects associated with writing and maintaining complex end-to-end UI tests.

Initial setup takes only a few minutes, and even less technical people can start writing tests, add assertions, and easily modify existing tests when needed. This results in being able to write tests up to 15x faster than with Selenium-based tools, and spending up to 95% less time on test maintenance - thanks to testRigor being packed with smart features.

Moreover, you can do cross-platform and cross-browser testing without major configuration steps. testRigor also allows 2FA, email testing, and SMS testing - included at no extra cost.

Let us consider the example from the UI testing using the supported tools section above. There is an application in React for creating a to-do list. The code has 2 test cases within the describe() block. When considering the test case in testRigor, things become much easier. Firstly, you need to create a test suite. During this suite creation, you can give the URL so that every time a new test case from this suite runs, a fresh instance of the application is opened in the browser. You can also specify the browser of your choice from the suggested options. This covers your beforeEach() block from the above code. As you can tell, it is much simpler than creation explicit conditions.

Your actual test case will look like this:
check that page does not contain checkboxes below "what needs to be done?"
enter "Buy groceries for Friday dinner" into "What needs to be done?"
enter enter into "testrigor.com test"
check that page contains "Buy groceries for Friday dinner" below "What needs to be done?"

In the afterEach() block, testRigor automatically takes screenshots of every step. Each test case run captures detailed screenshots along with a video recording of the whole test execution.

How to do End-to-end Testing with testRigor

Let us take the example of an e-commerce website that sells plants and other gardening needs. We will create end-to-end test cases in testRigor using plain English test steps.

Step 1: Log in to your testRigor app with your credentials.

Step 2: Set up the test suite for the website testing by providing the information below:

  • Test Suite Name: Provide a relevant and self-explanatory name.
  • Type of testing: Select from the following options: Desktop Web Testing, Mobile Web Testing, Native and Hybrid Mobile, based on your test requirements.
  • URL to run test on: Provide the application URL that you want to test.
  • Testing credentials for your web/mobile app to test functionality which requires user to login: You can provide the app’s user login credentials here and need not write them separately in the test steps then. The login functionality will be taken care of automatically using the keyword login.
  • OS and Browser: Choose the OS Browser combination on which you want to run the test cases.
  • Number of test cases to generate using AI: If you wish, you can choose to generate test cases based on the App Description text, which works on generative AI.

Step 3: Click Create Test Suite.

On the next screen, you can let AI generate the test case based on the App Description you provided during the Test Suite creation. However, for now, select do not generate any test, since we will write the test steps ourselves.

Step 4: To create a new custom test case yourself, click Add Custom Test Case.

Step 5: Provide the test case Description and start adding the test steps.

For the application under test, i.e., e-commerce website, we will perform below test steps:

  • Search for a product
  • Add it to the cart
  • Verify that the product is present in the cart

Test Case: Search and Add to Cart

Step 1: We will add test steps on the test case editor screen one by one.

testRigor automatically navigates to the website URL you provided during the Test Suite creation. There is no need to use any separate function for it. Here is the website homepage, which we intend to test.

First, we want to search for a product in the search box. Unlike traditional testing tools, you can identify the UI element using the text you see on the screen. You need not use any CSS/XPath identifiers.

For this search box, we see the text “What are you looking for?” So, to activate the search box, we will use the exact text in the first test step using plain English:
click "What are you looking for?"

Step 2: Once the cursor is in the search box, we will type the product name (lily), and press enter to start the search.

type "lily"
enter enter

Search lists all products with the “lily” keyword on the webpage.

Step 3: The lily plant we are searching for needs the screen to be scrolled; for that testRigor provides a command. Scroll down until the product is present on the screen:

scroll down until page contains "Zephyranthes Lily, Rain Lily (Red)"

When the product is found on the screen, testRigor stops scrolling.

Step 4: Click on the product name to view the details:

click "Zephyranthes Lily, Rain Lily (Red)"

After the click, the product details are displayed on the screen as below, with the default Quantity as 1.

Step 5: Lets say, we want to change the Quantity to 3, so here we use the testRigor command to select from a list.

select "3" from "Quantity"
After choosing the correct Quantity, add the product to the cart.
click "Add to cart"

The product is successfully added to the cart, and the “Added to your cart:” message is displayed on webpage.

Step 6: To assert that the message is successfully displayed, use a simple assertion command as below:

check that page contains "Added to your cart:"

Step 7: After this check, we will view the contents of the cart by clicking View cart as below:

click "View cart"

Step 8: Now we will again check that the product is present in the cart, under heading “Your cart” using the below assertion. With testRigor, it is really easy to specify the location of an element on the screen.

check that page contains "Zephyranthes Lily, Rain Lily (Red)" under "Your cart"

Complete Test Case

Here is how the complete test case will look in the testRigor app. The test steps are simple in plain English, enabling everyone in your team to write and execute them.

Click Add and Run.

Execution Results

Once the test is executed, you can view the execution details, such as execution status, time spent in execution, screenshots, error messages, logs, video recordings of the test execution, etc. In case of any failure, there are logs and error text that are available easily in a few clicks.

You can also download the complete execution with steps and screenshots in PDF or Word format through the View Execution option.

testRigor’s Capabilities

Apart from the simplistic test case design and execution, there are some advanced features that help you test your application using simple English commands.

  • Reusable Rules (Subroutines): You can easily create functions for the test steps that you use repeatedly. You can use the Reusable Rules to create such functions and call them in test cases by simply writing their names. See the example of Reusable Rules.
  • Global Variables and Data Sets: You can import data from external files or create your own global variables and data sets in testRigor to use them in data-driven testing.
  • 2FA, QR Code, and Captcha Resolution: testRigor easily manages the 2FA, QR Code, and Captcha resolution through its simple English commands.
  • Email, Phone Call, and SMS Testing: Use simple English commands to test the email, phone calls, and SMS. These commands are useful for validating 2FA scenarios, with OTPs and authentication codes being sent to email, phone calls, or via phone text.
  • File Upload/ Download Testing: Execute the test steps involving file download or file upload without the requirement of any third-party software. You can also validate the contents of the files using testRigor’s simple English commands.
  • Database Testing: Execute database queries and validate the results fetched.

testRigor enables you to test web, mobile (hybrid, native), API, and desktop apps with minimum effort and maintenance.

Additional Resources

Conclusion

With e-commerce website building, it becomes imperative to have reliable, well-tested building blocks. If the framework offers various modules and themes, they should be user-friendly. For instance, Prestashop provides many options for building your website, including the ability to use provided blocks or customize them to suit your needs. Once your website is operational, the good testing strategies described in this article can help you build a strong testing strategy.

Join the next wave of functional testing now.
A testRigor specialist will walk you through our platform with a custom demo.