-
Notifications
You must be signed in to change notification settings - Fork 0
Testing
Testing Tracks is fairly simple. For its tests 3 different technologies are used:
- Ruby unit tests (in
$RAILS_ROOT/test) - RSpec (in
$RAILS_ROOT/spec) - Cucumber (in
$RAILS_ROOT/features)
The tests make use of some gems which need to be installed first
Install required gems with
bundle install
Assuming you’ve already checked out the source code using git, change to the root directory of the project ($RAILS_ROOT) and run
rake test
If it completes successfully 0 failures, you’re good to go!
To run the Rspec tests run
rake spec
For integration testing Tracks uses cucumber. For those features that require javscript/ajax, Tracks uses Selenium on Webrat
To run the features excluding the selenium features and the work-in-progress (wip) features, run
rake cucumber
To run the features that make use of Selenium on Webrat, run
rake cucumber:selenium
To run the features that are work in progress run these:
rake cucumber:selenium_wiprake cucumber:wip
To run a feature by hand run these. Please note the different RAILS_ENV value and the -p usage for selenium:
RAILS_ENV=cucumber cucumber features/my_feature.featureRAILS_ENV=selenium cucumber -p selenium features/my_feature.feature
If you encounter problems runnig selenium tests, look at the problems with selenium tests section below.
h2. Running the tests headless
All tests will run on a headless setup except for the selenium tests. They will need a webbrowser which will need a running X-server.
You can solve this by running a virtual framebuffer X server. In Fedora, you need to install the packages xorg-x11-server-Xvfb and xorg-x11-apps
Xvfb :99 -ac -screen 0 1024x768x16 &
DISPLAY=:99.0 rake cucumber:selenium
killall Xvfb
We are migrating from the selenium test suite in the browser to cucumber and selenium on webrat. To run the selenium scripts that are not yet migrated, the following still applies:
To run the suite simply run Tracks in the test environment:
script/server -e test
in a separate command window, then run
rake test:acceptance
and Firefox will pop up and run the suite. If this does not work, you can run the suite manually by launching the server in test mode with the command above, and navigating to
http://localhost:3000/selenium/ in your browser of choice.
.h2 Problems with cucumber selenium tests
.h3 Tests doesn’t start
Firefox 3.x is required to run the selenium tests properly. It’s also recommanded to use an english version, to avoid problems due to the locale.
You can get an old version of firefox here.
.h3 Sqlite3 Lock exceptions
In the default settings sqlite locks the db immediately. This behavior can cause problems with the fast executing online tests. Add a timeout to the database.yml configuration file to avoid these errors.
For example:
test: &TEST
adapter: sqlite3
database: db/test.db
timeout: 10000