Magento Functional Testing Framework (MFTF)

Introduction to Magento Functional Testing Frameworks

For any Magento store owner, it has become very tough to sustain growth in the retail ecosystem. So it is essential to do continuous monitoring of your market and make changes in your Magento website.

These updates allow organizations to respond to the growing retail ecosystem quickly. But while building any changes to your eCommerce store, it becomes crucial to ensure a smooth user experience.

To walk parallelly with the ecosystem, complete Magento testing needs to be followed involving user behaviour simulation for proper performance evaluation. 


What is the Functional Testing Framework?

Functional Testing Framework is an open-source, cross-platform solution where we can build functional tests for a Magento application. These tests can be done at any time with the options of

  • Single tests
  • Multiple tests
  • All available tests

Tests usually cover the business entity’s functionality. The main motto is to find discrepancies between expected and real behaviour of the substance.


Focus of Magento Functional Testing Framework

  • Maintainability based on the overall structure and simple test creation.
  • Traceability for excellent reporting and logging capabilities.
  • Readability using declarative and precise XML test steps.
  • Modularity to test based on installed extensions and modules.
  • Customizability for pre-added texts.

Why do we need to perform functional testing?

Magento 2 provides a very complex architecture, and it becomes very tough to test everything manually. Also, manual testing can result in some errors due to complex flows. 

Although unit testing and integration testing can cover the entire code but still don’t guarantee that everything will implement quickly on different devices and browsers.

That is why a QA team should extensively utilize automatic tests, as it is the only workable solution to test the application thoroughly. It’s much faster and more efficient, less error-prone and along with test results you will also get additional data for free: like how long each test was performing, on which device, etc.


What is Magento Functional Testing Framework (MFTF)?

Magento Functional Testing Framework is a collection of ready-made tests that check if a Magento 2 system functionality works as expected.

The users of Magento functional Testing Framework

  • System integrators

MFTF provides excellent coverage with Magento in regression tests.

  • Contributors

These tests generate confidence and trust in the results of the changes introduced on the platform.

  • Extension developers

Can alter the predicted behaviour according to the customizations.


Key features of MFTF

  • Flexible due to modularity support.
  • Customizability, for existing tests.
  • Suitable, because of test suites.
  • Informative due to the reporting tool. 
  • Compatible due to web driver selection.

Benefits of MFTF over Unit Tests

  • XML

MFTF tests are written in XML, so, you do not have any need to learn PHP to write checks.

  • Merging

Merging is the most prominent feature of MFTF and for example, adding a new field to the existing registration form of Magento site.

In the case of unit testing, we need to create test cases again for the whole page, but in MFTF, we need to give additional attribute details and rest we can utilize the similar test case code from the core.


MFTF Outputs

  • Allure results dashboard.
  • Get PHP codeception tests
  • Allure results of formatted XML
  • Console logs and codeception results
  • HTML failure reports

Environment setup for MFTF

  • PHP Version

You need the latest update of the PHP version for your MFTF to work well. Make sure the version is above 7.2.13.

  • Composer

A composer is necessary for the work to be done. Click on this link to download and install the composer in your environment.

https://getcomposer.org/download/

  • JAVA

Make sure to install JAVA in your system else; the Selenium server won’t work.

  • Selenium Server

Make sure to install the selenium jar file, which can help you further in running the MFTF test cases.

Download the jar file and place the same in the Magento root directory. Here is the link to download the selenium jar file.

https://www.seleniumhq.org/download/

  • Web browser driver

Make sure to use a good web browser driver. Preferably, you can choose from Mozilla, Chrome and Safari. 


Steps to setup Magento Functional Testing Framework

Step 1 – Install Magento 2.3

Download the Magento 2.3 and extract it to your localhost directory. After that open the Magento directory on your browser and install the Magento setup.

Step 2 – Install dependencies

To install the Magento Functional Testing Framework, follow the below command:-

composer install -d dev/tests/acceptance/

Step 3 – Build the project

In the Magento project root, run:-

vendor/bin/mftf build:project

Step 4 – Edit Environmental settings

Edit the .env file to match your system. Run:

vim dev/tests/acceptance/.env

Mention the following parameters, which are required for tests –

  • MAGENTO_BASE_URL
  • MAGENTO_BACKEND_NAME
  • MAGENTO_ADMIN_USERNAME
  • MAGENTO_ADMIN_PASSWORD

Step 5 – Enable the Magento CLI commands

Run the given command to enable the MFTF to send Magento CLI commands to your Magento instance.

cp dev/tests/acceptance/.htaccess.sample

dev/tests/acceptance/.htaccess

Step 6 – Generate and run tests

Run the Selenium server in another terminal

Run the Selenium server in the terminal. Both selenium jar file and web browser driver should attain the same place.

For example, the following commands can be used for Google Chrome – 

cd<path_to_directory_with_selenium_server_and_webdriver>/Java-Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone-3.14.0.jar


Why hire MagnoStack’s Magento certified developers?

Magento Functional Testing Framework is already a power-packed tool, although it lacks some core tests for Magento. But you can develop tests for your projects based on it, and some organizations already do that.

MagnoStack, an award-winning Magento web development company, provides the expertise and skillset of Magento 2 Certified Associate Developers and Professional Front End Developers. 

We have highly experienced Magento 2 Front End Developers who will keep in mind your brand identity and your target audience while developing your application.

Our expert team of developers can make your application feature-rich through our Magento Integration and Magento Extension development services.

Blog CTA

Get in touch with our expert developers & consultants

We'll get back to you within 24 hours

Talk to our expert

Leave a Reply

Your email address will not be published. Required fields are marked *

This website uses cookies to ensure you get the best experience on our website. By using this site you agree to the use of cookies.Learn More Accept Cookies

Subscribe for Monthly Newsletter

Digital Newsletter about Magento & eCommerce.

X