SimpleCov is not picking up any coverage for our project
Our rspec configuration file has
SimpleCov.start
RSpec.configure do |c|
c.mock_framework = :rr
end
Every test file has the configuration file required in it. Our test run results in the following output (when we don't have it enabled in the IDE):
Coverage report generated for RSpec to C:/Program Files/JetBrains/RubyMine 3.2.4/bin/coverage. 0 / 0 LOC (0.0%) covered.
It finds nothing. We can not get even a little result. Anyone have any idea what I may be doing wrong? Seems like it should be simple :)
gems involved
rspec 2.6.0
simplecov 0.5.0
simplecov-html 0.5.0
rr 1.0.4
This is in a windows environment.
请先登录再写评论。
We did manage to get it to work after a few weeks experimentation, however it still does not integrate with the IDE (so you can see the coverage percent next to each file in your project). If someone could tell us how to make the integration feature work, we'd be most grateful.
To make simplecov work, we had to create a .simplecov file in the root of our project that contained the following (note, nothing else was necessary, it just worked from here):
module SimpleCov::Configuration
def clean_filters
@filters = []
end
end
SimpleCov.configure do
clean_filters
load_adapter 'test_frameworks'
add_filter '/Ruby192/'
# You can add_filter here to add anything else you don't want to cover
end
SimpleCov.at_exit do
base_result = {}
# This next bit is to show what files we have no coverage for. Without these lines, uncovered files are not reported...
Dir["#{SimpleCov.root}/**/*.rb"].each do |file|
absolute = File::expand_path(file)
next unless absolute.start_with?(SimpleCov.root)
next if SimpleCov.result.original_result.has_key?(absolute)
lines = File.readlines(absolute).size
base_result[absolute] = [0]*lines
end
merged = SimpleCov.result.original_result.merge_resultset(base_result)
result = SimpleCov::Result.new(merged)
result.command_name = SimpleCov.result.command_name
result.format!
puts "covered_percent: #{result.covered_percent}"
minimum_coverage = 80
if result.covered_percent < minimum_coverage
error_message = "Coverage too low: #{result.covered_percent.round(2)}%, should be #{minimum_coverage}%"
puts "##teamcity[buildStatus status=\'FAILURE\' text=\'{build.status.text}; #{error_message}\']"
raise error_message
end
end
SimpleCov.start 'test_frameworks'