Skip to content
Mo Morsi edited this page Feb 9, 2014 · 2 revisions

Omega comes with two test suites, one based on rspec testing the main Ruby simulation and the other on qunit testing the web frontend.

Both are independent of each other and are meant to run in seperate contexts.

Prerequisites

This tutorial assumes you have a local copy of Omega retrieved from git

git clone http://github.com/movitto/omege.git

Also you have setup and installed the necessary dependencies to run Omega.

RSpec

All that is needed to test the ruby library is rspec:

gem install rspec

From there simply run

rake spec

Note there are alot of tests, to speed things up on multi-core systems, install parallel_tests

gem install parallel_tests

Test suites and directories can also be individually run to verify particular components:

rspec spec/motel/location_spec.rb
rspec spec/cosmos

To immediately exit on the first failing test use --fail-fast

rspec spec/missions --fail-fast

To run specific tests, use -e:

rspec spec/manufactured/rjr/movement_spec.rb -e move_entity_in_system

RSpec provides many useful formatting, debugging, and utility mechanisms, see the documentation for the complete list.

QUnit

Setup

The QUnit test suite verifying the Omega Web Frontend requires a few additional steps to setup.

  • A running omega-server (see caveats below)
ruby -Ilib ./bin/omega-server
  • A running omega web frontend
rake site:preview
  • A frontend & proxy to omega & the omega test suite. Add the following to your omega config in /etc/httpd/conf.d/omega.conf:
ProxyPreserveHost On
ProxyPass /womega http://localhost:4567/
ProxyPassReverse /womega http://localhost:4567/

## when testing omega:
ProxyPass /omega http://localhost:8888
ProxyPassReverse /omega http://localhost:8888
Alias /omega-test /home/mmorsi/workspace/omega/site/tests/
  • Make sure to reload apache:
sudo service httpd reload

Running

From there simply navigate to http://localhost/omega-test and the test suite will automatically run.

Note it will take a little while to complete (~20s locally) during which the browser will probably become unresponsive as many different tests are being run testing many different asynchronous components.

Caveats

There are a few caveats when running the test suite. Most of these are just issues to be resolved / on the TODO list.

Test Isolation

Currently the QUnit tests aren't completely isolated, in certain situations a few tests could fail due to shared components (such as dialogs) transgressing into an invalid state.

On the same note, the qunit test suite requires a running omega-server to invoke, but in all cases the result of the operation is discarded / mock'd locally. The actual calls need to be stubbed at some point to isolate the test suite (and to remove the running omega-server dep)

Session Invalidations

If you had previously navigated to an Omega simulation (even if you didn't login) make sure to clear the Omega related cookies before running the test suite.

This can be done via the 'session' tab in firebug.

Currently there is a bug in the test suite where certain tests will fail if there is a pre-existing user session (despite logic inplace to remove this). When this is resolved, this note will be removed

Command Line Invocation

Currently we'd like to investigate mechanisms which to run the test suite via the cmd line (and add it as another rake task similar to rspec).

phantom.js seems to be a possible solution, though needs to be furthur investigated.

Clone this wiki locally