簡體   English   中英

使用Simplecov運行現有TestUnit測試和覆蓋的RSpec

[英]Running RSpec With Existing TestUnit tests and coverage with Simplecov

我是ROR的新手,想知道Simplecov是否在同一個項目中為TestUnit和RSpec測試提供測試覆蓋率?

我正在將我們在RSpec中編寫的一些測試從獨立的webapp遷移到當前使用TestUnit的現有webapp。

我知道RSpec和TestUnit都可以存在於同一個項目中,但我還沒有看到Simplecov如何為兩個測試框架生成覆蓋。

當我運行命令行bundle exec rake spec時,我得到:

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

當我運行bundle exec rake test我會生成測試覆蓋率。

計划是將所有內容從TestUnit遷移到rspec,但是有400多個測試,我們希望在遷移到TestUnit時讓Simplecov覆蓋TestUnit和RSpec測試。

我確定我的配置中肯定存在不正確的內容

任何幫助將非常感激!

我有以下設置:

--- 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__)

這不直接回答你的問題,但如果它有幫助,我有一個bash腳本,為你從TestUnit移植到RSpec做了很多工作。 它位於https://github.com/Noreaster76/porter 您可以使用它來轉換TestUnit文件,在稍微清理一下結果之后,您就不會遇到必須同時運行RSpec和TestUnit的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM