Running RSpec with existing TestUnit tests and coverage using Simplecov

I am new to ROR and am wondering if Simplecov provides test coverage for TestUnit and RSpec tests in the same project?

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

I know that RSpec and TestUnit can live in the same project, but I could not see how Simplecov will generate coverage for both test frameworks.

When I run the exec rake spec command-line package, 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.

We plan to migrate everything from TestUnit to rspec, but with 400+ tests we want the TestUnit and RSpec tests to be covered by Simplecov while we go to TestUnit.

I am sure there must be something wrong with my configuration

Any help would be greatly appreciated!

I have the following setup:

--- 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__) 
+4
source share
1 answer

This does not answer your question directly, but if it helps, I have a bash script that does most of the work for you to port from TestUnit to RSpec. It is located at https://github.com/Noreaster76/porter . You can use it to convert TestUnit files, and after a little deletion of the results you would not have problems starting RSpec and TestUnit.

0
source

Source: https://habr.com/ru/post/1432013/


All Articles