Friday, September 12, 2008

Implementation of CruiseControl.rb and RCov

CruiseControl.rb is Ruby based continuous integration tool which is used for continuous build process including testing, email notification. Also provide the details of all build.

On the other hand, RCov is very well known code coverage tool for Ruby. It is used to get the information of test coverage.

These two tools are so good together and their implementation is incredibly simple which is describe below:

Download: Click here to download. After completing the download unpack it.

Add project: Go to the unpacked directory from command prompt and execute following command:
cruise add <project-name> --url <project-url>.
This will create a directory under cruise data, then checks out your project to ./cruise/projects/<project name>/work/

Start Cruise: Execute command: cruise start. It will run your CrouiseControl on port 3333. Browse - http://localhost:3333/. If everything is going well, you will see the the CruiseControl dashboard with project list. You can build your project and see the build report.

Create database: You have to create test database and edit database.yml to connect with database, performing rake RAILS_ENV=test db:migrate, running rake test and making sure that it passes.

Install rails_rcov: Install RCov gem to CruiseControl server by using gem install RCov and plugin to project folder by using following command:
 ruby script/plugin install
Add rake task: If you installed the plugin into your project you have some useful rake tasks. Now you have to add “cruise.rake” task to the “lib/tasks” directory of your Ruby on Rails project with following:
desc 'Continuous build target'
task :cruise do
mkdir_p out unless out if out

ENV['SHOW_ONLY'] = 'models,lib,helpers'
mv 'coverage/units', "#{out}/unit test coverage" if out

ENV['SHOW_ONLY'] = 'controllers'
mv 'coverage/functionals',"#{out}/functional test coverage" if out

That’s all, now your project has code coverage. You can browse the source within the browser from dashboard and see which lines are covered and which are not. Enjoy!!

It was written on September 2008. Please click here to read documentation by

1 comment:

  1. Just stumbled on your blog - you should really check out metric_fu: - easy to install and you get a bunch more metrics than just rcov - enjoy!