Gabriel Mesquita
Gabriel Mesquita

Reputation: 2411

Ruby on Rails coverage tool that shows what is not being covered

I am developing an application using rails. Since the start we are using rspec to test our application. And we are using simplecov as a tool to show our test coverage.

But simplecov only shows the percentage of coverage inside a file, My question is if there is a tool that shows what line of code is not being covered?

Upvotes: 0

Views: 1750

Answers (2)

yusefu
yusefu

Reputation: 144

We use this in my workplace: https://codecov.io/#features

Codecov is used to help developers determine what lines of code were executed by their tests. There are three primary terms used to indicate the results of your tests: hit, partial and miss.

The value of 54% comes from a calculation of hit / ( hits + partial + miss) = coverage.

  1. A hit is a line (aka statement) that is fully executed by your tests.
  2. A partial is a statement (typically a branch) that is not fully executed.

Example if true:... will always be a partial hit because the branch was never skipped because true is always true.

  1. A miss is a statement that was not executed by tests.

A grade of 54%, in simple terms, says "Half my code is tested". Use Codecov to investigate methods and statements in your code that are not tested to help guide you on where to write your next test and increase the coverage.

Upvotes: 0

Yana Agun Siswanto
Yana Agun Siswanto

Reputation: 2032

If you click on the file name, simplecov will show you the line that is covered (with green) and not covered (with reds). enter image description here

Upvotes: 3

Related Questions