Par Charlotte, Directrice Marketing & Commerciale.

For 202 ecommerce, as for any member of the IT community, designing long haul and stable solutions for our clients is a battle we pursue everyday.

As long as we act as an agency within the specific context of a merchant, the amount of necessary tests is known and limited.

However, as soon as we design modules intented for all PrestaShop merchants, the amount of tests goes skyrocketing : several PrestaShop and PHP/ MySQL versions, contexts of specific use etc.. This is when a thoughtful testing approach is required, including automated quality control processes.

The predicted end of manual testing ?

Over the past 10 years, several automated testing technologies were born and some names are constantly thrown back at diner tables of geek socialites, leading to think noone ever proceeds to manual testing anymore.

Of course, this is greatly exaggerated. Human tests remain necessary. The new principle is, alike many areas, to use IT to prepare the work load and “maximize” the potential of humain brain.

In parrallel, this is about integrating tests as soon as possible in the development chain, hereby preventing the case of one discovering some components are out of order after a complex implementation was completed.

Unit tests vs integration tests

Unit testing is about individually testing each component of the computer code.
An integration test will check whether several components properly function together or not.

For instance, if you were to design a calculator :
– unit testing will consist of testing the addition process injecting 1 + 2 in the component managing additions and then checking the result is 3.
– an integration test will test the addition process typing successively the keys “1 + 2 =” and then checking the result displayed on screen is 3.

This second test validates different components working together simultaneously : the keyboard, the component managing additions and the screen. However if the test fails, how can we figure out which component is ill ? Should the screen display 4, maybe the keyboard sends 2 no matter which key is typed !

This example perfectly illustrates how we need to perform both families of tests : unit tests while components are being developped, then integration tests once components are available.

Both families of tests can be automated but integration test automation is more complicated : in order to perform the integration test above, one would have to simulate clics on the calculator keys and then read the result displayed on screen. Thereby, integration tests generally remain manual.

Unit testing : everyone talks about it, hardly anyone does it

Most developpers no longer need to be convinced about necessity and efficiency of coding while performing unit tests, but they might as well actually do it !

In fact, performing unit tests requires a change of work method and escalated rigor. Moreover, despite being acknowleged as a best practice, little documentation or tools are available.

Simply type “PrestaShop unit testing” in Google and observe very few results are relevant. Despite the fact some embryonic unit tests have appeared with PrestaShop 1.7, there is no solution covering all versions and enabling complete tests whether official or from the PrestaShop community.

Looking back 6 months ago, our tests were almost entirely conducted manually and they were all integration tests. This was time-consuming and did not guarantee 100% quality.

We have since set up a series of tools and adapted our development methods to introduce unit tests and / or non-regression tests. Among other tasks, we have had to support PrestaShop versions prior to 1.7 and simulate the context of a PrestaShop store. (this last point was added in PrestaShop 1.7.3 but as our modules need to be retrocompatible, so do our tests !)

Docker : a valuable ally

For test automation it is necessary to set up a processing chain far outrunning the unit test by itself. E.g how to test different PHP versions, as mentioned above.

One key component of our processing chain is Docker, enabling to perform both human tests and PHPunit tests in a virtualized environment, created on demand.

This first article regarding our internal technology choices will be followed by more content in our Lab section. We will also share some tools of the processing chain. Stay tuned : Follow-us or subscribe to our newsletter !

 

Leave a reply