Using SimpleCov in a Ruby Project

I am trying to use the simplecov pearl in a Ruby project. However, I failed. Here is what I have done so far.

My project structure: ProjectFolder - lib - test

I have my tests in test and source code in lib. I created test_helper.rb in the test directory and added the following.

require 'simplecov' SimpleCov.start 

Then I put `require 'test / test_helper.rb' in each test file. It happened that sometimes a report was created, and sometimes not. And when this happened, it was inconsistent.

All the tutorials I found were for Rails, so I will go back to StackOverflow again to show me the way.

+4
source share
1 answer

Rcov / SimpleCov will only report test coverage.

To get a full coverage report, you need to make sure that the full test suite is launched as the last test to create a full coverage report.

You will also want to make sure that this is the first request in your test_helper.rb file.

From the documentation :

Note. If SimpleCov starts after the application code is already (via require), it will not be able to track your files and their coverage! SimpleCov.start must be released before any of your required application code!

+4
source

Source: https://habr.com/ru/post/1480367/


All Articles