문제

사용 simple_cov Rails 앱의 gem에 대해 테스트하지 않은 파일을 보고서에 포함시킬 수 있나요?

  • 그렇다면 어떻게?

  • 그렇지 않다면 해당 파일은 적용 범위에 포함되어야 합니다. 그렇죠?

도움이 되었습니까?

해결책

편집해 보세요 config/environments/test.rb 다음 줄을 설정합니다.

config.eager_load = false

에게 true 이런 방식으로 전체 앱이 로드되고 simplecov가 이를 읽습니다.

다른 팁

열망하는 것은 코드 적용 범위가있는 테스트 스위트를 실행할 때 전체 레일 앱을로드합니다. Rails.application.eager_load!spec_helper.rb를 추가하십시오.

SimpleCov는 테스트를 늦추므로 쉘 환경 변수를 사용하여 켜기 위해 켜짐을 켭니다.일반적으로 내 spec_helper.rb / rails_helper.rb는 다음과 같이 보입니다.

if ENV['COVERAGE']
  require 'simplecov'
  # some SimpleCov setup, e.g. formatters
  SimpleCov.start 'rails'
end

ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'

Rails.application.eager_load! if ENV['COVERAGE']
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top