Preparing a test database
If this is the first time tests are being run against Redmine, we'll need to first initialize the testing environment.
A test database should first be defined in the path /path/to/redmine/config/database.yml
, and then the following rake tasks can be run to set up the database:
rake db:drop db:create db:migrate redmine:plugins:migrate redmine:load_default_data RAILS_ENV=test
The first command drops the tests database, creates a fresh one, and then runs the Redmine core migrations and all migrations for any installed plugins.
The second command is used to seed the test database with Redmine's default data. For a peek into what constitutes default data, see the contents of /path/to/redmine/lib/redmine/default_data/loader.rb
.
Once the test database has been initialized, we can use the rake tasks introduced at the beginning of this chapter to run the tests for our plugin.
Note that running the full suite can take a bit of time, so if you're trying to just run a single test...