How Drupal 8 Improves CI and Automated Testing
The End-to-end Testing Revolution in Drupal 8
When we discuss Continuous Integration, one of the core principles is a process for self-testing your Drupal site build. Automated testing was a thorny prospect in previous versions of the Drupal CMS. That is, until the release of Drupal 8. This post covers how and why Drupal 8's support for unit tests make a holistic, end-to-end testing process more attainable than ever.
Before diving in, you might want to check out some posts that cover our continuous integration workflow in more detail:
- Continuous Integration Efforts Get Easier with Drupal 8
- DIY Continuous Integration (Video)
- Continuous Integration Delivers Advantages for Business
End-to-end Testing & Drupal 8's Framework
The arrival of Drupal 8 heralds a major re-architecting of the open source CMS. The latest version of Drupal adopts the Symfony2 framework and Object Oriented Programming (OOP). The new framework gives developers easy access to Dependency Injection, mocking of objects and other programming patterns that consolidate a single unit of code.
Unit testing was very difficult and verging on impossible before Drupal 8. Drupal did have a Simple Test framework built in but it was convoluted and functional code wasn’t very encapsulated before the new version.
Reusable Code, Lower Maintenance Costs
Having the ability to test units, which in our case is a single function within a class, will inspire developers to write better and more testable code. These smaller units of reliable code will be repurposed for future use and lead to lower cost of maintenance, which is an added business benefit.
Swapping PhantomCSS for WebDriverCSS
In our early endeavors into visual regression testing, we leveraged PhantomCSS and CasperJS as our toolset for testing purposes. We’ve overhauled this tool set slightly, thanks to research and constant evaluation by Lisa Ridley, one of Promet’s senior solutions architects.
The Ultimate Goal
The final aim is to incorporate the basic unit tests with a series of the system, behavioral and visual testing to create a process that resembles this pyramid of testing, with the “manual” portion of our testing process becoming a much smaller component:
Image courtesy of software testing blogger Alister Scott
How We Get There: Behavior Driven Development (BDD)
We’re still big believers in BDD here at Promet. Writing test cases in a shared language with the client can provide assurances for both parties that the project is moving forward according to plan. Using human language also eliminates a lot of unnecessary jargon. We feel confident that our approach to testing will make for smoother migrations and help tackle technical projects with APIs and integrations.
Like What You See in Our Testing Process? Want to learn how your team of Drupal developers can make it happen?
We train Drupal development teams in BDD and end-to-end testing. Make this process relevant to your project goals with a custom training session. Our experts will train your team so that the process becomes standardized and is repeatable for future development teams.