How Drupal 8 Improves CI and Automated Testing
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.
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.
Selenium2, WebdriverCSS, and WebdriverIO have become our toolset of choice. WebdriverIO and WebdriverCSS satisfy some of the basic requirements for our purposes at Promet since it handles tests written in Javascript and, being a Drupal shop, it’s one of the programming languages in which our developers are proficient. Additionally, it gives us the ability to test across different browsers and devices with a single test suite by leveraging the automated testing capabilities of services such as SauceLabs or Browserstack. We can test on Chrome, Firefox, Safari, and IE as well as different operating systems and mobile devices with tests written in WebdriverCSS and WebdriverIO.
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.
Other Insights & Resources you may like
Get our newsletter
Alright, so, software ate the world. That happened. Technology is now at the heart of every modern company, and as far as we can tell that isn’t changing. That’s the sitch. Our job is to make it more human.