Continuous integration meets Joomlatools Console

If you read our previous blog post, you will already be aware that we are big fans of continuous integration and automated testing.

Today we are happy to announce two new Joomlatools Console plugins to help get you started with automated testing for your own Joomla projects.

What is Codeception and how does Travis help

Codeception is a testing framework for PHP, with support for unit, functional and acceptance tests. Pre-prepared tests allow for a site to be quickly tested and ensure that no functionality is broken.

For example, how would you test a new feature and imagine that you had to explain how to test to a colleague?:

  1. I am on the home page ('/')
  2. I am going to login as a user
  3. I fill the username field with admin
  4. I fill the password field with admin
  5. I Click the login button
  6. I see the successful login message
  7. I would expect to be logged in now
  8. Because I don't see any errors

You'd explain what you were attempting to test in plain english, with replicable and easy steps, wouldn't you?

Now, let's take a look at how these steps could be written in Codeception with some actual code:

$I->amGoingTo('Login as admin');
$I->fillField('input#username', 'admin');
$I->fillField('input#password', 'admin');
$I->see('Welcome admin');
$I->expect('To be logged in now');
$I->dontSee('Username and password does not match');

Amazing how similar they are, aren't they? In this way you can write automated tests that other users of the system can understand as well.

Codeception allows us to test different kinds of user perspectives and site scenarios. By doing so, we can simulate a user's natural flow throughout an application to make sure the app is working as expected.

But, how do you ensure these tests are run at appropriate times?

Travis is a solution to help with just this very situation. Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub.

Therefore, each time you make a commit to either staging or master your tests will be run automatically in the background. You'll receive email notifications of both successes and failures!

What's more it's completely free for open source projects. Nice!

Getting started

Let's quickly run you through how to set this up. First, let's start off with a brand new site:

joomla site:create continuous-integration

Be sure to initialise a new GitHub hosted project for this new site.

Note you will have to sign up to Travis: and enable travis for this GitHub hosted project.

Codeception and Travis

Setting up codeception

Installation is easy:

$ joomla plugin:install joomlatools/console-codeception

Next, let's bootstrap your project with a codeception acceptance suite:

joomla codeception:bootstrap continuous-integration

This suite includes some sample tests and best practices we've developed.

In order to get your host machine configured for codeception, please refer to the Requirements of the README

Once installed run your tests by:

selenium-server --help

followed by:

codecept run acceptance

Setting up travis

Installation is easy:

$ joomla plugin:install joomlatools/console-travis

Bootstrapping the existing project:

joomla travis:bootstrap continuous-integration

will create your travis integration for you.

Each time you create a new feature branch and push changes, travis will create a virtualised environment from which codeception tests can be run automatically.

And voila, automated testing for your Joomla project!

Get started

Supercharge your Joomla development with Joomlatools Console which ships as standard with our Joomlatools Vagrant Box.

Download the Joomlatools Vagrant Box

Be the first to know about upcoming extensions, features, and news by following us on Twitter or Facebook and Linkedin.

Written by

Paul Yiend

24 Oct 2018

Join 23000+ others and subscribe to our newsletter!