Skip to content

Developer guide: Automated tests

drkitty edited this page Feb 2, 2015 · 1 revision

As of this commit, Cyder's test coverage is far from complete. However, it's still important to run tests before merging a branch that touches any code or configuration.

Running tests

Tests require a test database. If you haven't previously run any tests in a particular Cyder instance, you need to grant the Cyder user full privileges on the database whose name is formed by prepending "test_" to the Cyder database name. However, don't actually create the database manually.

The first time you run tests in a Cyder instance, run tests like this:

FORCE_DB=1 ./manage.py test cyder

That's also how you run tests if the schema has changed since the last time you ran them.

If the schema hasn't changed since the last time you ran tests, you can reuse the existing test database by omitting FORCE_DB=1:

./manage.py test cyder

If you prefer friendlier test errors and failures and less verbose output, consider using nose-progressive. Install it with pip and use it by adding the --with-progressive option:

./manage.py test --with-progressive cyder

Writing tests

All test classes should inherit from cyder.base.tests.TestCase unless there's a good reason not to. Each test should have a docstring that describes the test's purpose. Comments are also very helpful, especially when it's unclear what a test is testing.

Clone this wiki locally