4
votes

I'm new to ROR and wondering if Simplecov provides tests coverage for both TestUnit and RSpec tests in the same project?

I am in the process of migrating some tests we wrote in RSpec from a standalone webapp to an existing webapp that currently uses TestUnit.

I know that both RSpec and TestUnit can live in the same project, but I haven't been able to see how Simplecov will generate coverage for both test frameworks.

When I run on the command line bundle exec rake spec I get:

Coverage report generated for RSpec to /.../coverage. 0 / 0 LOC (0.0%) covered.

when I run bundle exec rake test I get test coverage generated.

The plan is to migrate everything from TestUnit to rspec but with 400+ tests we want to have both TestUnit and RSpec tests covered by Simplecov whilst we migrate to TestUnit.

I'm sure there must be something incorrect in my configuration

Any help would be much appreciated!

I have the following set up:

--- Rakefile ---

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'simplecov'

if Rails.env == 'test' || Rails.env == 'development'
  require 'ci/reporter/rake/test_unit'
  require 'ci/reporter/rake/rspec'
end

SimpleCov.start 'rails' do
  add_filter "/test/"
  add_filter "/spec/"
end

-- spec/spec_helper.rb --

ENV["RAILS_ENV"] ||= 'test'

require 'simplecov'
SimpleCov.start 'rails'

require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'

-- test/test_helper.rb --

require 'simplecov'
SimpleCov.start 'rails' do
  add_filter "/vendor/"
end

ENV["RAILS_ENV"] = "test"

require File.expand_path('../../config/environment', __FILE__)
1
It doesn't address your issue directly, but you may find this StackOverflow question of some reference.Paul Fioravanti

1 Answers

0
votes

This doesn't answer your question directly, but if it helps, I have a bash script that does a lot of the work for you for porting from TestUnit to RSpec. It's at https://github.com/Noreaster76/porter. You could use it to convert your TestUnit files, and after cleaning up the results a bit, you wouldn't have the issue of having to run both RSpec and TestUnit.