We've moved discussions to Discord

How to add SimpleCov

Jake Smith
I tried adding https://github.com/colszowka/simplecov to my app using the Jumpstart template, and I'm unable to generate any coverage reports.  I placed 

require 'simplecov'
SimpleCov.start

at the very top of my `test/test_helper.rb` file like their README suggests, but when I run the tests, it doesn't generate the coverage folder.

Has anyone had success in adding SimpleCov to this project template?
Chris Oliver
Hmm, that's interesting. I haven't used simplecov in JSP personally, but curious why that wouldn't have generated anything.
Tiago Casanova
Hi Jake Smith !

I've already added SimpleCov to my project without hassle. I also tested adding it on a clean cloned repository successfully 👍

ENV details:
  • ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
  • Rails 6.0.3.2
  • simplecov (0.18.5)

Assuming you followed the instructions at https://github.com/colszowka/simplecov#getting-started, where did you place it in the Gemfile? Note that the Jumpstart default Gemfile already has a :test group, I placed mine at the end of it (gem 'simplecov', require: false). However, I also tested placing inside all bundler groups...no change.

It might be your .gitignore file tricking you. Did you add it there already?

Screenshot 2020-06-22 at 11.20.01.png 937 KB
Chris Oliver
For fun, I made a RailsByte to install SimpleCov: https://railsbytes.com/public/templates/zPdsaZ
Jake Smith
Hey guys, thanks for the response!  I tried adding SimpleCov again from scratch, and I'm still not able to get a coverage folder created.  My tests run fine, but after they finish, it is not creating that folder.

I added SimpleCov to the Gemfile like this:

image.png 74.6 KB


Then I added this to `test_helper.rb`:

image.png 106 KB


I think I'm following the same approach you both did.  This leads me to believe I've done something outside of SimpleCov to get in its way.
Jake Smith
Ugh...I've been adding those two lines to the top of the wrong `test_helper.rb` file.  I was adding it to the one in `lib/jumpstart`... I'm so silly...
Chris Oliver
Haha! It happens to the best of us.
Notifications
You’re not receiving notifications from this thread.