6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Rails】 Simple Covを使ってみる

Posted at

テストカバレッジ計測ツールSimple Covを使ってみます。

導入方法

Gemfile
group :test do
  gem 'simplecov'
.
.
end
$ bundle install

spec_helper.rbの末尾に以下の2行を追加。

spec/spec_helper.rb
require 'simplecov'
SimpleCov.start 'rails'

.gitignorecoverrageディレクトリを追加(すでにある場合は不要)

.gitignore
/coverage/

使い方

テストを実行すると/coverageディレクトリに解析結果が出力されます。

$ bin/rspec
# テスト結果が並ぶ
.
.
.
Coverage report generated for RSpec to /Users/d0ne1s/sample_app/coverage. 224 / 778 LOC (28.79%) covered.

coverage/index.htmlをブラウザで開くと、解析結果を確認することができます。
 2020-03-02 19.44.48.png

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?