If you’re a CKAN developer, if you’re developing an extension for CKAN, or if
you’re just installing CKAN from source, you should make sure that CKAN’s tests
pass for your copy of CKAN. This section explains how to run CKAN’s tests.

CKAN’s testsuite contains automated tests for both the back-end (Python) and
the front-end (JavaScript). In addition, the correct functionality of the
complete front-end (HTML, CSS, JavaScript) on all supported browsers should be
tested manually.

To run CKAN’s tests using PostgreSQL as the database, you have to give the
--with-pylons=test-core.ini option on the command line. This command will
run the tests for CKAN core and for the core extensions:

nosetests--ckan--with-pylons=test-core.inickanckanext

The speed of the PostgreSQL tests can be improved by running PostgreSQL in
memory and turning off durability, as described
in the PostgreSQL documentation.

By default the tests will keep the database between test runs. If you wish to
drop and reinitialize the database before the run you can use the reset-db
option:

If you’re a CKAN developer or extension developer and your new code requires a
change to CKAN’s model, you’ll need to write a migration script. To ensure that
the migration script itself gets tested, you should run the tests with
the --ckan-migration option, for example:

nosetests--ckan--ckan-migration--with-pylons=test-core.inickanckanext

By default tests are run using the model defined in ckan/model.
With the --ckan-migration option the tests will run using a database that
has been created by running the migration scripts in ckan/migration, which
is how the database is created and upgraded in production.

Warning

A common error when wanting to run tests against a particular database is to
change sqlalchemy.url in test.ini or test-core.ini. The problem
is that these are versioned files and people have checked in these by
mistake, creating problems for other developers.

Pylons nose plugin failed to run. If this is the case, then within a couple of lines of running nosetests you’ll see this warning: Unable to load plugin pylons followed by an error message. Fix the error here first`.

The Python module ‘Pylons’ is not installed into you Python environment. Confirm this with:

This error usually results from running a test which involves search functionality, which requires using a PostgreSQL database, but another (such as SQLite) is configured. The particular test is either missing a @search_related decorator or there is a mixup with the test configuration files leading to the wrong database being used.

This means your solr_url is not corresponding with your SOLR. When running tests, it is usually easiest to change your set-up to match the default solr_url in test-core.ini. Often this means switching to multi-core - see Configure Solr Multi-core.

In order to test in all the needed browsers you’ll need access to
all the above browser versions. Firefox and Chrome should be easy
whatever platform you are on. Internet Explorer is a little trickier.
You’ll need Virtual Machines.

Firstly we have a primer page. If you’ve touched any of the core
front-end code you’ll need to check if the primer is rendering
correctly. The primer is located at:
http://localhost:5000/testing/primer

Secondly whilst writing a new feature you should endeavour to test
in at least in your core browser and an alternative browser as often
as you can.

Thirdly you should fully test all new features that have a front-end
element in all browsers before making your pull request into
CKAN master.