Aníbal Rojas
2005-Oct-13 23:31 UTC
Integrating Coverage (of testing) into Rails application
I have been trying to integrate Coverage: http://rubyforge.org/frs/shownotes.php?release_id=361 Into a Rails application to get coverage reports for the Source Code / Tests, but I am not sure about how to proceed, should I add the: require ''coverage'' to the tests? Or modify the rake task to invoke it as the Agile Web Development with Rails says: depot> ruby -rcoverage test/functional/store_controller_test.rb I tried this invocation for a single test and just got an empy index.html in a "coverage" folder I also tried: C:\sandboxes\bob\trunk>rake ruby_opts="-rcoverage" getting: (in C:/sandboxes/bob/trunk) ruby -Ilib;test "c:/ruby/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_lo ader.rb" "test/unit/blog_test.rb" "test/unit/localization_test.rb" "test/unit/us er_test.rb" c:/ruby/lib/ruby/gems/1.8/gems/coverage-0.2-/lib/coverage.rb:264: warning: regex p has `}'' without escape execute Loaded suite c:/ruby/lib/ruby/gems/1.8/gems/rake-0.5.4/lib/rake/rake_test_loader Where the message "warning: regexp has `}'' without escape" is induced by the option passed. Any help will be greatly appreaciated -- Aníbal Rojas http://www.lacaraoscura.com anibalrojas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Scott Barron
2005-Oct-15 22:39 UTC
Re: Integrating Coverage (of testing) into Rails application
On Oct 13, 2005, at 7:31 PM, Aníbal Rojas wrote:> I have been trying to integrate Coverage: > > http://rubyforge.org/frs/shownotes.php?release_id=361 > > Into a Rails application to get coverage reports for the Source Code / > Tests, but I am not sure about how to proceed, should I add the: > > require ''coverage'' > > to the tests? Or modify the rake task to invoke it as the Agile Web > Development with Rails says: > > depot> ruby -rcoverage test/functional/store_controller_test.rb > > I tried this invocation for a single test and just got an empy > index.html in a "coverage" folder >You can get both coverage and rcov to run a Rails app, but I''ll say up front that it is *very* slow. I''ve currently got a system set up that runs coverage analysis via the unit tests and is only marginally slower than the unit tests themselves. The problem is I have to hack Ruby itself to make it do this. I''m currently working on trying to get this to work in pure ruby (I think I need to contact some gurus, though). If that won''t be possible I can probably get it to work as a C extension, along the lines of ruby-prof or the zenhacks stuff. When it''s done it''ll just be something you can run from RAILS_ROOT and generate a report. Stay tuned ... -Scott