How to test a Plone addon

To better understand how to test a Plone addon, the best thing is to create a new Plone package from scratch and use it to see different testing techniques.

We are going to use the plonecli tool heavily because it lets you create new Plone packages and related features such as content types, views, and vocabularies, all using simple commands.

Create Package

First, we need to install plonecli:

$ pip install plonecli --user

Note

This command will install plonecli in the user site-packages according to the official documentation. Feel free to install it using your preferred alternative method (virtualenv, pipenv, pyenv).

Note

If you have already installed plonecli, please update at least bobtemplates.plone to the most recent version (>= 5.0.1) because there are some important fixes needed for this training.

Now we can create a new package:

$ plonecli create addon plonetraining.testing

Buildout

Run buildout:

$ cd plonetraining.testing
$ plonecli build

Note

This command will create a virtualenv, install dependencies and run buildout.

Let’s run some tests! plonecli provides some default tests when creating a new package:

$ plonecli test

Let’s run all tests, including robot tests (we will cover these later):

$ plonecli test --all

Note

If you get an error about missing geckodriver, you will have to install geckodriver. On macOS, you can use brew install geckodriver. On Ubuntu, you can use apt install firefox-geckodriver. Then re-run plonecli test --all.