User:Fuzzymee/sandbox

SimpleCov
SimpleCov is a Ruby API (application program interface) that was first released August 21st, 2010 by Christoph Olzowka. Since the initial release it has gone through 38 iterations leading up to its most recent version (0.13.0) which was released January 25th, 2017. SimpleCov works on top of Ruby's built-in code coverage library to make analyzing the program's code coverage simpler and more intuitive. When testing a program it is important that the developers test as many lines of code as possible to find all possible bugs. Code coverage is often represented as the percent of lines currently tested by the program's testing suites. SimpleCov is designed to make this process easier for the developers.

What is SimpleCov?
SimpleCov is a code coverage tool which checks for the gaps in the test coverage. It is important to know about this since third party libraries (RubyGems) are often used in real world rails applications which can lead to untested codes. It uses the existing code coverage libraries in Ruby and aggregates the various testing suites and compiles their results into a single comprehensive interface. This allows for the developers to minimize the loss in coverage that could be seen otherwise. For example, if two testing suites both had a code coverage of 80%, without SimpleCov the developer may not know whether they cover the same 80%, or if somewhere between 1%-20% of the code is currently not covered. SimpleCov would look at both testing suites and merge the results showing the true code coverage of the combined testing suites. Once the results have been retrieved, SimpleCov allows the developers to further organize the results through sorting, merging or formatting to best fit their needs.

How To Use SimpleCov:
1. add following line to your gem file gem ‘simplecov’ 2. run bundle install

3. Add following lines to your spec_helper file. require ‘simplecov’

SimpleCov.start 4. run ‘rake spec’

5. SimpleCov can produce misleading reports alongside spring. To avoid this you need to change following parameters of the test file. config.serve_static_files = false
 * 1) FOR RAILS 4.0

config.eager_load = false 2. FOR RAILS 5.0 config.public_file_server.enabled = false

config.eager_load = false 6. run “spring stop” and “spring rspec path_to_file”

SimpleCov is integrated as a gem (known as simplecov-html) in gemfile. It already has its dependency. The simplecov code coverage is integrated along with the tests. There is also rcov style formatter for simplecov which is known as simplecov-rcov. This formatter is aimed for Hudson such that ruby metric plugin can be used.

RCov Usage:
1. Add simplecov-rcov to gemfile

2. execute bundle install.

3. Add following lines to test.rb file require 'simplecov-rcov'

SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter