Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Unit Testing

I have been having some problems with a Magento site recently and am looking for a way to check the integrity of a Magento site at any given point.

Unit Testing jumps out as one method of doing this but I would assume it would be a very big job to write a whole lot of tests to check everything in the site is working as it should.

Can anyone involved in unit testing and magento advise on the following:

  1. Is it possible to test the whole site and not just custom modules - is so some examples of tests would be amazing.
  2. Given that the site is heavily linked to the database - how would it be possible to fully test the site without disturbing the database
  3. Are there any better ways to automaticlly check the integrity of a magento site

When I say integrity i really mean that there are no faults on the site - shipping, payment etc are all working correctly.

like image 458
David Avatar asked Sep 10 '11 23:09

David


People also ask

Is SpecFlow a unit test?

SpecFlow supports several unit test framework you can use to execute your tests. To use a specific unit test provider, you have to add it's dedicated NuGet package to your project. You can only have one of these packages added to your project at once.

What is flutter unit test?

Lets add unit tests to your flutter application. Unit tests are handy for verifying the behavior of a single function, method, or class. The test package provides the core framework for writing unit tests, and the flutter_test package provides additional utilities for testing Widgets.


1 Answers

This is a big task, however there are Magento community members who have tackled it.

The EcomDev_PHPUnit module provides a framework for unit testing Magento, but it doesn't contain any actual tests. It could (and has) been used to test core functionality or modules that you have developed yourself.

One of the key advantages of the EcomDev module is that it does provide 100% isolation of your database. It creates an exact copy of your database structure, and then uses fixtures (see pg 6 of the manual) to insert data into those tables to create test pre-requisites. This is powerful and best practice, but does require quite a bit of setup.

You can try using phpMyAdmin to export data into YAML in readiness for creating fixtures.

The alternative is to create and automate a comprehensive Selenium test suite for the browser UI. In fact, the best solution is to prepare both unit and UI tests as there will be areas that can only be tested in one functional domain. There is a significant amount of business logic built into Magento's Javascript (all the validation.js for example) that PHPUnit can't easily test, Selenium is your best option here.

There have been early conversations about creating a repository of unit tests to cover the core functionality, however keep in mind that Magento 2.0 (planned for 2012) advertises complete test coverage.

like image 129
Jonathan Day Avatar answered Oct 20 '22 00:10

Jonathan Day