Custom rake task for Hudson

Custom rake task for Hudson

When I tried to setup up a Hudson job for continuously running our unit and Cucumber tests, I came across several difficulties (e.g. producing proper output which is readable by Hudson). These ultimately lead to writing a custom Rake task for properly setting up and running the tests.

The task requires the ci_reporter plugin to generate JUnit output from the unit tests (Cucumber supports this out of the box). Additionally, everything required for gathering code coverage data is included as well.

Put this into lib/tasks/hudson.rb:

require 'ci/reporter/rake/test_unit'
require 'rcov/rcovtask'

namespace :hudson do
 def report_path

 task :all => [:report_setup] do

 task :test => ['ci:setup:testunit'] do

 task :coverage
 %w[unit functional integration].each do |target|
   namespace :coverage do do |t|
       t.libs << "test"
       t.test_files = FileList["test/#{target}/**/*_test.rb"]
       t.output_dir = "#{report_path}/rcov"
       t.verbose = true
       t.rcov_opts << '--rails --aggregate --no-html'
   task :coverage => "hudson:coverage:#{target}"
 end'cucumber') do |t|
   t.cucumber_opts = %{--format junit --out #{report_path}/features}
   t.rcov = true
   t.rcov_opts = %w{--rails --aggregate --exclude osx\/objc,gems\/,spec\/,\.bundler\/,features\/}
   t.rcov_opts << %[-o "#{report_path}/rcov"]

 task :report_setup do
   rm_rf ''
   rm_rf report_path

   ENV['CI_REPORTS'] = %{#{report_path}/tests}


Now configure the following build stepts in Hudson:

  1. Execute shell command: bundle install
  2. Execute Rake: db:schema:load RAILS_ENV=test
  3. Execute Rake: hudson:all RAILS_ENV=test

When configuring the Rcov post build step, use this directory: hudson/reports/rcov. Now Hudson should run all your Rails tests as well as the Cucumber tests and gather the coverage data.

Über den Autor

Bewertet mit durchschnittlich
Sternen von

fortytools by zvoove für Ihre Branche

No items found.

Jetzt 30 Tage kostenlos und unverbindlich testen

Alle Funktionen stehen uneingeschränkt zur Verfügung. Keine Software-Installation, keine Probleme mit Updates. Einfach via Browser Einloggen und fertig. Von jedem internetfähigen Gerät.
Heute kostenlos testen!
Nutzerbewertung: 4,8 von 5 Sternen