Update testing instructions. Convert page to Markdown.

Dan Rice 2014-06-11 08:42:01 -07:00
parent fdf09f42f9
commit 8e431bd902

@ -1,145 +1,118 @@
h1. Testing # Testing
Testing Tracks is fairly simple. For its tests 3 different technologies are used: Testing Tracks is fairly simple. For its tests two different technologies are used:
* Ruby unit tests (in @$RAILS_ROOT/test@) * MiniTest unit, functional, and integration tests (in `/test`)
* RSpec (in @$RAILS_ROOT/spec@) * Cucumber acceptance tests (in `/features`)
* Cucumber (in @$RAILS_ROOT/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
<pre> ### Running the unit, functional, and integration tests
<code>
bundle install
</code>
</pre>
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
```
<pre> To run a single test, include the name of the file and the name of the test itself, e.g.
<code> ```
bundle exec rake test bin/rake test test/models/project_test.rb test_has_default_context
</code> ```
</pre>
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 ### Running the acceptance tests
NOTE: rspec tests are not actively maintained.
To run the Rspec tests run
<pre>
<code>
bundle exec rake spec
</code>
</pre>
h2. Running the cucumber test suite
For integration testing Tracks uses cucumber. For those features that require javscript/ajax, Tracks uses Selenium and Capybara 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 To run all the features excluding the work-in-progress (wip) features, run
<pre> ```
<code>
bundle exec rake cucumber RAILS_ENV=development bundle exec rake cucumber RAILS_ENV=development
</code> ```
</pre>
This will execute all features, including those using Selenium. This will execute all features, including those using Selenium.
To run the features that are work in progress run these: To run the features that are work in progress run these:
<pre> ```
<code>
bundle exec rake cucumber:wip bundle exec rake cucumber:wip
</code> ```
</pre>
To run a feature by hand run these. To run a feature by hand run these.
<pre> ```
<code>
bundle exec cucumber features/my_feature.feature bundle exec cucumber features/my_feature.feature
</code> ```
</pre>
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. 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. 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. 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: Run the features using webkit:
<pre> ```
<code>
bundle exec rake cucumber JS_DRIVER=webkit bundle exec rake cucumber JS_DRIVER=webkit
</code> ```
</pre>
h3. Framebuffer #### Framebuffer
For the framebuffer in Fedora, you need to install the packages xorg-x11-server-Xvfb and xorg-x11-apps For the framebuffer in Fedora, you need to install the packages xorg-x11-server-Xvfb and xorg-x11-apps
<pre> ```
<code>
Xvfb :99 -ac -screen 0 1024x768x16 & Xvfb :99 -ac -screen 0 1024x768x16 &
DISPLAY=:99.0 bundle exec rake cucumber:selenium DISPLAY=:99.0 bundle exec rake cucumber:selenium
killall Xvfb killall Xvfb
</code> ```
</pre>
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: 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: To run the suite simply run Tracks in the test environment:
<pre> ```
<code> bundle exec script/server -e test
bundle exec script/server -e test ```
</code>
</pre>
in a separate command window, then run in a separate command window, then run
```
<pre> bundle exec rake test:acceptance
<code> ```
bundle exec rake test:acceptance
</code>
</pre>
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 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. 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. 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. 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. 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: For example:
<pre><code> ```
test: &TEST test: &TEST
adapter: sqlite3 adapter: sqlite3
database: db/test.db database: db/test.db
timeout: 10000 timeout: 10000
</code></pre> ```