0

We're working on several Magento projects with CE 1.9.X and we're looking for a testing framework to do unit and functional testing. I've done a little research and I've seen posts talking about Magento 1.X problems with unit testing due to its design.

So I'm not sure if unit testing it's possible on Magento 1.X projects. If unit testing it's possible, can you suggest me a framework you use? I'm also interested in integration testing and maybe functional testing. So far, I've seen this options:

1

We're working on several Magento projects with CE 1.9.X and we're looking for a testing framework to do unit and functional testing.

I've done a little research and I've seen posts talking about Magento 1.X problems with functional testing due to its design.

Don't you mean problems with unit testing? Functional testing is black box testing, which does not know anything about the code, so the software design does not matter for it.


For functional testing any browser testing framework does the job. Magento TAF has been used to test the Magento core and you could probably use it but I can't recommend it. When I tried it, it seemed not very stable.

I can recommend Magium though, it is a browser testing framework with a clean PHP API that comes with a bunch of predefined tests for Magento. Those can be configured easily to work with different themes and data.


Unit testing in Magento 1 is a different and more advanced topic. It works well if you manage to write code as independent from Magento as possible. You will find some good advice here: http://de.slideshare.net/vinaikopp/writing-testable-code-for-magento-1-and-2

As a framework, you'll only need PHPUnit.


And then there's integration testing. You did not ask for it but I often see it mixed up with unit tests and it is the kind of testing I do most in Magento 1 projects, where integration with the framework is what matters.

EcomDev_PHPUnit has already been mentioned, and it is the framework of my choice but I have to say that while it is powerful, it takes a while to master and has many quirks.

A better choice to begin with is probably to write integration tests in plain PHPUnit with a custom bootstrap. Here's a minmal testing framework built upon this approach: https://github.com/digitalpianism/testframework

And another interesting alternative which also has features for functional testing: https://github.com/code-x/magento-xtest

  • Thanks for your answer! As you said the "testing problems" I've mentioned are related to unit testing, not to functional testing, I will edit the post. I' m newbie in testing, not only in Magento Testing.. Even then your answer it's really helpful to begin with testing. I'll research a little bit more, thanks for yor help ! – José Luis Expósito Feb 16 '17 at 8:57
1

https://github.com/EcomDev/EcomDev_PHPUnit works also quite well with Magento 1.9.x. Please note that the link for the manual in the Readme is broken. You can get it at the issues page (https://github.com/EcomDev/EcomDev_PHPUnit/issues/270).

  • Thank you! I'll take a look. I can't spend too much time researching so.. Have you ever used it? I need to know it's a real alternative. – José Luis Expósito Feb 14 '17 at 8:01
  • Yes. I use it for all my newer projects. Works great so far. – Peter Bättig Feb 15 '17 at 9:03
0

Magento Testing Framework works with Magento 1 as well. Functional tests that are delivered together with Magento 1.9.x are written based on this framework.

  • Thank you! I will read its documentation to make it work, I am completely lost in this field.. – José Luis Expósito Feb 13 '17 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.