4
0

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.

【RSpec】テスト実行結果を見やすくする。

Last updated at Posted at 2020-04-06

問題

RSpecを使っていると、テスト実行結果が、

$ bundle exec rspec
.....

Finished in 4.05 seconds (files took 5.14 seconds to load)
5 examples, 0 failures

このように表示される、この.....が各テストをパスした、という表示だが、使い初めから、違和感があった。
分かりづらい、見ずらい、、

原因、解決

その後、RSpecについて調べている中で、
.rspecに

--format documentation

を追加。

そうすると、出力結果が、

$ bundle exec rspec

TestHelper
test_method
is expected to eq "rspecでhelperをテスト"

Products
GET #show
リクエストに成功する
商品名が含まれる
商品詳細が含まれる
商品価格が含まれる

Finished in 4.14 seconds (files took 5.31 seconds to load)
5 examples, 0 failures

このように変わり、パスしたテスト名が表示されるようになり、見やすくなった。
これが標準でもいいのでは無いかと思うレベルだが、テストの数が多くなるに伴い出力が多くなる為、後々は元に戻したくなるのかな、とも感じた。

終わりに

転職の為、未経験の状態からRailsを学習しております。正しい知識を着実に身に着け、実力のあるエンジニアになりたいと考えています。継続して投稿していく中で、その為のインプットも必然的に増え、成長に繋がるかと考えています。
今現在、初心者だからといって言い訳はできないですが、投稿の内容に間違っているところや、付け加えるべきところが多々あるかと思いますので、ご指摘頂けると幸いです。この記事を読んで下さりありがとうございます。

4
0
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
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?