Contact
Contact
My account
09.06.17

Glpi now uses atoum for its unit tests!

About 2 years ago, we’ve begin to add some unit tests in the GLPI project; thanks to Valentin and Remi Collet. The PHPUnit framework has been used, since this is the most "common" choice for a PHP project.

Unfortunately, many parts of the code are not tested yet... This is a huge job; but we’re working on it. Nowadays, each new feature implemented in GLPI is unit tested; and we plan to spend time this summer to work on all of this.Why now?I personally appreciate atoum since its very beginning, and I’ve proposed to switch a while ago. Since we plan to add more and more tests; switching while there are still a few tests was easier. That’s why it’s been done now.So, why to switch?Well... Speaking of PHP unit testing frameworks, there are not so many possible choices. PHPunit is probably the oldest unit testing framework available for PHP; and it does the job, really. atoum is a more recent and modern choice, and it has some interesting capabilities:

  • testing variables types (if you test an integer and get a string, this is not correct),
  • wonderful mocking system (that permit to mock php native functions, constants, ...),
  • use closure to test outputs, exceptions, ... (way more interesting than phpunit’s annotations),
  • concurrent run of tests (even if it have been disabled for GLPI),
  • fully isolated tests,
  • chained calls,
  • more natural way to write tests (this is maybe just my point of view - but this is really more simple to me).

Also, GLPI is a French project, most core team members are French, just as atoum! 😉On a technical noteSwitching from PHPUnit to atoum is not something very difficult, especially if you did not yet use advanced features (which is the case for GLPI); but it is not really something that can be scripted. In facts, it could for some common cases, but reviewing tests is not something bad globally. Also, re-writing tests is a very good start point to learn new syntax, asserters and possibilities.For the GLPI project, we’ve spent two days working on the rewrite. What we had to take care of:

  • atoum is not permissive at all. Every notice in the code will make tests fail per default (which is a good point); we had to fix them;
  • we’re doing kind of functional tests and not only unit tests. Some existing tests used to change existing values in the database, before resetting them. That cannot be done running tests concurrently;
  • atoum does not support dependencies across tests; which phpunit does. It should seem a bad point, but the point is "tests are isolated". So... They cannot be dependent, we had to find another way;
  • session usage: GLPI uses many data in the session; and that is really a problem for testing... We had to disable concurrent runs mainly because of that :’(

The futureIn a close future, we plan to improve our unit tests; since many parts of the code are not tested at all. We also plan to split our unique directory into several ones, making possible to disable concurrent runs only on functional tests, not on the whole tests suite.Johan Cwiklinski.

You may also like these articles

19.06.25
Congratulations! We are happy to announce our new Silver GLPI Network partner in Brazil: Lanlink With over 36 years of history, Lanlink is a company specialized in IT infrastructure, cloud, data & AI, digital productivity, and information security. A partner of global leaders such as Microsoft,...
13.06.25
GLPI Agent 1.15 has been released. We are proud to announce this new release comes with signed windows MSI package and signed windows binaries. You can download it on the GLPI Agent github project: https://github.com/glpi-project/glpi-agent/releases/tag/1.15 This version comes with some fixes a...
11.06.25
We’re excited to introduce a powerful new feature in our OauthSSO plugin! The latest major release of OauthSSO brings expanded compatibility with the addition of a new authentication provider: Apple. This means users can now log in using their Apple account, alongside the ...
09.06.25
Congratulations! We are happy to announce our new Silver GLPI Network partner in Ivory Coast: Synerj Expertises Founded in October 2024, SYNERJ EXPERTISES is an IT solutions integrator based in Abidjan, Côte d’Ivoire. Their mission is to provide businesses with tailored solutions aimed at helpin...
09.06.25
We’re excited to announce the launch of our brand-new GLPI Help Center—your go-to destination for everything GLPI! GLPI is now more accessible than ever at help.glpi-project.org!  This dedicated space has been designed to help you get the most out of GLPI. You’ll find: Step...
09.06.25
Congratulations! We are happy to announce our new Silver GLPI Network partner in Mauritius: ITOM Consult ITOM Consult supports its clients in making informed choices and decisions regarding IT Operations Management (ITOM). Their comprehensive vision, enhanced by multi-vendor experience, enables the...
09.06.25
Congratulations! We are happy to announce our new Silver GLPI Network partner in Senegal: Expert IS EXPERT IS is a company specializing in the digital sector. Its activities are organized around three main areas: INFRASTRUCTURE, focusing on the implementation of information systems; DIGITALIZATION,...
09.06.25
On May 15, Teclib’ brought its teams together for Teclib’ Day 2025, an event that combines assessment, vision, and team spirit. This day, held at Mama Shelter in Paris, was the perfect opportunity to take stock of our progress, thank the teams for their dedication, and strengthen our ties throug...
22.05.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Malaysia: Fronix SDN BHD FRONIX SDN BHD (FSB) is an information and communication technology (ICT) service organization offering specialized solutions and services for the telecommunications, public, private, and gov...
22.05.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Spain: Consultores IT 365 Consultores IT 365 is a 100% Spanish company with over 15 years of experience, specializing in transforming ICT into a strategic engine for businesses. Their team is made up of consultants de...
14.05.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Brazil: JMBA Soluções Founded in 2018, JMBA Soluções is an IT consulting company based in São Paulo. It focuses on Cloud computing, collaboration, data centers, networks, and security solutions, offering full sup...
09.05.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in the United States: Synapse Software For over 15 years, Synapse Software has been committed to automating business processes. Through its automation platforms, and IT service and asset management, Synapse Software help...
29.04.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in France: Catamania Catamania is a French digital consulting and services company with 1,200 employees and a turnover of €100M in 2024. Since its creation in 1999, it has supported the digital transformation of its cl...
29.04.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Switzerland: DOS Group SA More than 2,000 companies in Switzerland and around the world trust the DOS Group for their ICT and digital solutions. With over 20 years of experience, versatile expertise, and a commitment ...
29.04.25
We are pleased to announce that GLPI Agent 1.14 is now available — update now! You can download it from the official project page on GitHub: https://github.com/glpi-project/glpi-agent/releases/tag/1.14 This version brings a few fixes and improvements, including: Regarding packages, here are the hi...
15.04.25
Congratulations to Imagunet on this tremendous achievement! From Silver to Gold! Our first Gold Partner in Latin America! After several years of collaboration, we are proud to announce that Imagunet, based in Colombia 🇨🇴, has become our first Gold Partner in the region. Imagunet is a leading s...
07.04.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Brazil: VLCloud IT Services VLCloud is a company specialized in IT solutions and services. It is committed to thoroughly analyzing each client’s IT environment through a team of highly qualified and experienced prof...
07.04.25
We are thrilled to announce the release of a new GLPI Network plugin: Cloud Inventory! Available starting from the Basic subscription level and on the Cloud. CloudInventory allows automatic and manual synchronization of resources hosted by various cloud providers (OVH, AWS, Azure, Google Cloud, etc....
31.03.25
Congratulations! We are pleased to announce that Adactim, already a trusted GLPI Network partner in Tunisia, is now expanding its partnership in France as a new Silver GLPI Network partner! 🎉 ADACTIM France, official partner of Teclib’, stands out for its expertise in GLPI integration, IT outso...
31.03.25
Congratulations! We are pleased to announce our new Silver GLPI Network partner in Hungary: Intalion Intalion Rendszerintegrátor Kft. specializes in IT system integration and service management, helping companies streamline operations and improve efficiency. As a GLPI partner, they offer customized...
1 2 3 15
chevron-right linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram