mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Update testing instructions. Convert page to Markdown.
parent
fdf09f42f9
commit
8e431bd902
1 changed files with 49 additions and 76 deletions
|
|
@ -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
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
bundle install
|
||||
</code>
|
||||
</pre>
|
||||
### 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
|
||||
```
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
bundle exec rake test
|
||||
</code>
|
||||
</pre>
|
||||
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
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
bundle exec rake spec
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
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
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
```
|
||||
bundle exec rake cucumber RAILS_ENV=development
|
||||
</code>
|
||||
</pre>
|
||||
```
|
||||
|
||||
This will execute all features, including those using Selenium.
|
||||
|
||||
To run the features that are work in progress run these:
|
||||
<pre>
|
||||
<code>
|
||||
```
|
||||
bundle exec rake cucumber:wip
|
||||
</code>
|
||||
</pre>
|
||||
```
|
||||
|
||||
To run a feature by hand run these.
|
||||
<pre>
|
||||
<code>
|
||||
```
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
```
|
||||
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
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
```
|
||||
Xvfb :99 -ac -screen 0 1024x768x16 &
|
||||
|
||||
DISPLAY=:99.0 bundle exec rake cucumber:selenium
|
||||
|
||||
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:
|
||||
|
||||
To run the suite simply run Tracks in the test environment:
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
bundle exec script/server -e test
|
||||
</code>
|
||||
</pre>
|
||||
```
|
||||
bundle exec script/server -e test
|
||||
```
|
||||
|
||||
in a separate command window, then run
|
||||
|
||||
<pre>
|
||||
<code>
|
||||
bundle exec rake test:acceptance
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
```
|
||||
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:
|
||||
<pre><code>
|
||||
```
|
||||
test: &TEST
|
||||
adapter: sqlite3
|
||||
database: db/test.db
|
||||
timeout: 10000
|
||||
</code></pre>
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue