Microservices From Day One by Cloves Carneiro Jr. & Tim Schmelmer

Microservices From Day One by Cloves Carneiro Jr. & Tim Schmelmer

Author:Cloves Carneiro Jr. & Tim Schmelmer
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


SimpleCov.start

RSpec.configure do |config|

config.after(:suite) do

simplecov = RSpec.describe('Test coverage')

example = simplecov.example('must exceed 85 percent'){

expect( SimpleCov.result.covered_percent ).to be > 85

}

simplecov.run

if example.execution_result.status != :passed

RSpec.configuration.reporter.example_failed(example)

end

end

end

Listing 8-5.spec/spec_helper.rb that fails test suite runs below 85% coverage

Continuous Integration to Improve Code Reviews

If you want to use a less forceful approach than failing the entire test suite, but still want to keep track of declining code coverage numbers, you can instead (or additionally) try and integrate coverage checks into your Continuous Integration (CI) build system.

When using the Jenkins project's CI system ( https://jenkins.io/ ), it can easily be extended with plugins to set up a workflow that processes SimpleCov-generated code coverage data. The DocLinks plugin ( https://wiki.jenkins-ci.org/display/JENKINS/DocLinks+plugin ) can be used to display formatted coverage reports, as shown in Figure 8-3.

Figure 8-3.Jenkins shows SimpleCov reports via the DocLinks plugin.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.