From 8e431bd9024643c7527d1ca48bea6ef0ce983e04 Mon Sep 17 00:00:00 2001 From: Dan Rice Date: Wed, 11 Jun 2014 08:42:01 -0700 Subject: [PATCH] Update testing instructions. Convert page to Markdown. --- Testing.textile => Testing.md | 125 +++++++++++++--------------------- 1 file changed, 49 insertions(+), 76 deletions(-) rename Testing.textile => Testing.md (60%) diff --git a/Testing.textile b/Testing.md similarity index 60% rename from Testing.textile rename to Testing.md index 31113bd..af4cddb 100644 --- a/Testing.textile +++ b/Testing.md @@ -1,145 +1,118 @@ -h1. Testing +# 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@) +Testing Tracks is fairly simple. For its tests two different technologies are used: +* MiniTest unit, functional, and integration tests (in `/test`) +* Cucumber acceptance tests (in `/features`) -h2. Setup +## Setup -The tests make use of some gems which need to be installed first +### Gems +The tests make use of some gems which need to be installed first. If you have previously done a `bundle install --without development test` you will need to edit your `.bundle/config` and re-run `bundle install`. -Install required gems with +## Running the tests -
-
-bundle install
-
-
+### Running the unit, functional, and integration tests -h2. Running the Rails test suite +From the root directory of the project, run +``` +bin/rake test +``` -Assuming you've already checked out the source code using git, change to the root directory of the project ($RAILS_ROOT) and run +To run an individual test file, append the name of the file, as in +``` +bin/rake test test/models/project_test.rb +``` -
-
-bundle exec rake test
-
-
+To run a single test, include the name of the file and the name of the test itself, e.g. +``` +bin/rake test test/models/project_test.rb test_has_default_context +``` -If it completes successfully 0 failures, you're good to go! +If it completes successfully with 0 failures, you're good to go! -h2. Running the RSpec test suite - -NOTE: rspec tests are not actively maintained. - -To run the Rspec tests run - -
-
-bundle exec rake spec
-
-
- -h2. Running the cucumber test suite +### Running the acceptance tests For integration testing Tracks uses cucumber. For those features that require javscript/ajax, Tracks uses Selenium and Capybara To run all the features excluding the work-in-progress (wip) features, run -
-
+```
 bundle exec rake cucumber RAILS_ENV=development
-
-
+``` This will execute all features, including those using Selenium. To run the features that are work in progress run these: -
-
+```
 bundle exec rake cucumber:wip
-
-
+``` To run a feature by hand run these. -
-
+```
 bundle exec cucumber features/my_feature.feature
-
-
+``` -If you encounter problems runnig selenium tests, look at the _Problems with cucumber selenium tests_ section below. +If you encounter problems running selenium tests, look at the _Problems with cucumber selenium tests_ section below. -h2. Running the tests headless +### 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 or by using the capybara-webkit driver. -h3. Using webkit +#### Using webkit Uncomment the capybara-webkit gem in the Gemfile and run bundle install. This will need the Qt development libraries on your system. Run the features using webkit: -
-
+```
 bundle exec rake cucumber JS_DRIVER=webkit
-
-
+``` -h3. Framebuffer +#### Framebuffer For the framebuffer 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 bundle exec rake cucumber:selenium
 
 killall Xvfb
-
-
+``` -h2. Running the old browser-based Selenium test suite +### Running the old browser-based Selenium test suite 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: -
-
-  bundle exec script/server -e test
-
-
+``` +bundle exec script/server -e test +``` in a separate command window, then run - -
-
-  bundle exec rake test:acceptance
-
-
- +``` +bundle exec 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 +### Problems with cucumber selenium tests -h3. Tests doesn't start +#### Tests doesn't start Firefox 3.x is required to run the selenium tests properly. It's also recommended to use an english version, to avoid problems due to the locale. You can get an old version of firefox "here":http://www.mozilla.org/en-US/firefox/all-older.html. -h3. Sqlite3 Lock exceptions +#### 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
-
+``` \ No newline at end of file