test/ directory and are organised by type.
Prerequisites
Before running tests you need:- A configured development database and a separate test database (see your
config/database.yml) - All gem dependencies installed, including the test group
If you previously ran
bundle install while skipping test dependencies, delete .bundle/config and run bundle install again to pick up the test gems.| Gem | Purpose |
|---|---|
rails-dom-testing | DOM assertions in controller tests |
capybara | Browser-based system tests |
rubocop | Static analysis (see Contributing) |
rubocop-performance | Performance cops |
rubocop-rails | Rails cops |
Setting up the test database
Create and migrate the test database before the first run:test/fixtures/ to seed test data. Rails loads them automatically when you run the test suite.
Running the full test suite
Run tests in parallel
Speed up the suite by settingPARALLEL_WORKERS to the number of parallel processes you want:
List available test tasks
Running specific tests
System tests (Capybara)
System tests drive a real browser via Capybara and require Chrome to be installed and available on yourPATH. Redmine uses selenium-webdriver (>= 4.11.0) to communicate with ChromeDriver. You need to have ChromeDriver installed and available on your PATH as well.
Environment variables for system tests
| Variable | Description |
|---|---|
CAPYBARA_SERVER_HOST | IP address the test server listens on (e.g. 0.0.0.0 for all interfaces) |
CAPYBARA_SERVER_PORT | Port for the Capybara test server |
CAPYBARA_APP_HOST | Custom application URL (default: localhost) |
SELENIUM_REMOTE_URL | Remote Selenium/ChromeDriver URL |
GOOGLE_CHROME_OPTS_ARGS | Comma-delimited Chrome options |
Run system tests in headless mode
Run against a remote Selenium instance (e.g. Docker)
SCM (version control) tests
Redmine supports multiple version control systems. Integration tests for each require a local test repository.{redmine_root}/tmp/test. If a test repository is not present, the tests that require it are automatically skipped.
LDAP tests
To run the LDAP authentication tests:Start a test LDAP server
Load the bundled LDAP export into your test LDAP server:The tests expect the server at
127.0.0.1:389 by default.Redmine.pm tests
These tests exercise the Apache mod_perl integration for repository access control. You need:- Apache with
mod_perlandmod_dav_svn Redmine.pmconfigured- An empty SVN repository accessible at
http://127.0.0.1/svn/ecookbook
REDMINE_TEST_DAV_SERVER if your SVN server is not on localhost:
Static analysis
RuboCop
RuboCop checks Ruby code against the project style rules. Run it before submitting a patch:Stylelint (CSS)
Troubleshooting
Tests fail with 'database does not exist'
Tests fail with 'database does not exist'
Create the test database and run migrations:
Missing test gems (LoadError)
Missing test gems (LoadError)
Delete your bundle config and reinstall with all groups:
Capybara tests fail: Chrome not found
Capybara tests fail: Chrome not found
Install Google Chrome and make sure
google-chrome or google-chrome-stable is on your PATH. Also install ChromeDriver matching your Chrome version and ensure it is on your PATH. Redmine uses selenium-webdriver to communicate with ChromeDriver.SCM tests are skipped
SCM tests are skipped
Test repositories have not been set up. Run:Repositories will be extracted to
tmp/test/.LDAP tests are skipped
LDAP tests are skipped
The LDAP server is not running or not reachable at
127.0.0.1:389. Start your test LDAP server and ensure it is accessible, or set REDMINE_TEST_LDAP_SERVER to point to the correct host.