October 2008
Beginner to intermediate
224 pages
5h 34m
English
By using a plug-in called RCov, you can always tell exactly what lines of code within your
application are covered. To use it, you’ll have to make a few
modifications to the project. First, you’ll need to install the
gem, and the Rails plug-in for coverage. As usual, omit
the sudo on the Windows platform:
$ sudo gem install rcov Password: Updating metadata for 104 gems from http://gems.rubyforge.org/ ..................................................................................... complete Building native extensions. This could take a while... Successfully installed rcov-0.8.1.2.0 1 gem installed Installing ri documentation for rcov-0.8.1.2.0... Installing RDoc documentation for rcov-0.8.1.2.0... lance-carlsons-macbook-pro:photos lancelotcarlson$ script/plugin install http://svn.codahale.com/rails_rcov + ./MIT-LICENSE + ./README + ./tasks/rails_rcov.rake
By default, this tool will measure coverage for all types of tests
independently. You will also find it useful to measure the total coverage
of all of your tests. To do so, you’ll need another rake task. Add the file called
lib/tasks/coverage.rake to the project, and make it
look like this:
require 'rcov/rcovtask' namespace :test do desc 'Aggregate code coverage for unit, functional and integration tests' Rcov::RcovTask.new(:coverage => 'db:test:prepare') do |t| t.libs << "test" t.test_files = FileList["test/unit/*_test.rb","test/functional/*_test.rb", "test/integration/*_test.rb"] t.output_dir = "coverage" t.verbose ...
Read now
Unlock full access