Created Testing (textile)

bsag 2011-07-16 05:58:29 -07:00
parent 27f094a371
commit 8f4cb0c85e

117
Testing.textile Normal file

@ -0,0 +1,117 @@
h1. Testing
Testing Tracks is fairly simple. All you need to do is install a couple of bundles and run the suite! All tests are stored in @$RAILS_ROOT/test@.
h2. Setup
The tests make use of some gems which need to be installed first
Install required gems with
<pre>
<code>
rake gems:install RAILS_ENV=test
rake gems:install RAILS_ENV=selenium
</code>
</pre>
h2. Running the Rails test suite
Assuming you've already checked out the source code using git, change to the root directory of the project ($RAILS_ROOT) and run
<pre>
<code>
rake test
</code>
</pre>
If it completes successfully 0 failures, you're good to go!
h2. Running the RSpec test suite
To run the Rspec tests run
<pre>
<code>
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 on Webrat
To run the features excluding the selenium features and the work-in-progress (wip) features, run
<pre>
<code>
rake cucumber
</code>
</pre>
To run the features that make use of Selenium on Webrat, run
<pre>
<code>
rake cucumber:selenium
</code>
</pre>
To run the features that are work in progress run these:
<pre>
<code>
rake cucumber:selenium_wip
rake cucumber:wip
</code>
</pre>
To run a feature by hand run these. Please note the different RAILS_ENV value and the -p usage for selenium:
<pre>
<code>
RAILS_ENV=cucumber cucumber features/my_feature.feature
RAILS_ENV=selenium cucumber -p selenium features/my_feature.feature
</code>
</pre>
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
<pre>
<code>
Xvfb :99 -ac -screen 0 1024x768x16 &
DISPLAY=:99.0 rake cucumber:selenium
killall Xvfb
</code>
</pre>
h2. 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>
script/server -e test
</code>
</pre>
in a separate command window, then run
<pre>
<code>
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
http://localhost:3000/selenium/ in your browser of choice.