-
Notifications
You must be signed in to change notification settings - Fork 27
Testing
The backend tests are located in bonnie/test/. Sample data used in the backend tests islocated in bonnie/test/fixtures. To execute all of the backend tests, run:
bundle exec rake
This will result in the generation of a coverage report using simplecov. The coverage report can be found in bonnie/coverage.
If you do not want to wait for the whole test suite to run, you can run individual test files by running:
rake TEST=<test/test_file_to_run>
It is important to remember to start each setup portion of new test files with 'dump_database' to ensure that any changes made to fixtures in previous tests do not hold. If you are going to add fixtures, do not add them to existing fixture sets (eg: records/base_set). Instead, create your own new set (eg: records/<your_set_name>) and place the new fixtures here.
The frontend tests are located in the models,views and integration directories found in bonnie/spec/javascripts. Sample data used in the frontend tests is located in bonnie/spec/javascripts/fixtures. These tests are written in coffeescript and make use of the jasmine testing framework. Code-coverage for the frontend tests is accomplished through the use of istanbul and teaspoon. To generate coverage reports, you will first have to install istanbul:
npm install -g istanbul
If the install command does not work, make sure you set the npm proxy
variable if applicable:
npm set proxy http://yourcompanyproxy.com:8080
To run the frontend tests, you can start the rails server and navigate to 127.0.0.1:3000/teaspoon
. Or alternatively to run the frontend tests and generate a coverage report, run:
rake teaspoon USE_COVERAGE=default
The generated coverage reports can be found in bonnie/coverage-frontend
Tests should avoid side effects by loading (likely in beforeEach ->
) their fixtures using the BonnieRouterCache.
At the startup of front-end tests execution, measure fixtures for jasmine tests are automatically loaded by setup/measure.js.erb
which searches the fixtures directory for all directories containing files titled measures.json
. Each of these files will be loaded, along with the value_sets.json
file that needs to exist with them, into an instance of BonnieRouter that will be stored.
In order load a specific state, use the command:
window.bonnieRouterCache.load(key)
where the key is the path from fixtures to the files. For example, use the command:
window.bonnieRouterCache.load('base_set')
to load the fixture bonnie/spec/javascripts/fixtures/measure_data/base_set/measures.json