simplecov 0.15.1 → 0.18.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +98 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +300 -115
- data/doc/alternate-formatters.md +20 -0
- data/lib/simplecov.rb +298 -45
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +24 -0
- data/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/lib/simplecov/combine/results_combiner.rb +60 -0
- data/lib/simplecov/command_guesser.rb +8 -3
- data/lib/simplecov/configuration.rb +95 -8
- data/lib/simplecov/defaults.rb +13 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +32 -3
- data/lib/simplecov/filter.rb +5 -2
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/formatter/multi_formatter.rb +4 -2
- data/lib/simplecov/formatter/simple_formatter.rb +6 -4
- data/lib/simplecov/last_run.rb +5 -1
- data/lib/simplecov/lines_classifier.rb +21 -5
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles.rb +11 -7
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/result.rb +41 -6
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +20 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +190 -109
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/useless_results_remover.rb +16 -0
- data/lib/simplecov/version.rb +3 -1
- metadata +44 -162
- data/.gitignore +0 -31
- data/.rspec +0 -3
- data/.rubocop.yml +0 -88
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/Gemfile +0 -38
- data/Rakefile +0 -39
- data/cucumber.yml +0 -13
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -45
- data/features/config_coverage_dir.feature +0 -33
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_formatters.feature +0 -77
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_profiles.feature +0 -44
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -121
- data/features/config_tracked_files.feature +0 -29
- data/features/config_tracked_files_relevant_lines.feature +0 -31
- data/features/cucumber_basic.feature +0 -29
- data/features/maximum_coverage_drop.feature +0 -89
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/minimum_coverage.feature +0 -59
- data/features/refuse_coverage_drop.feature +0 -95
- data/features/rspec_basic.feature +0 -32
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -37
- data/features/rspec_groups_using_filter_class.feature +0 -41
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -44
- data/features/step_definitions/simplecov_steps.rb +0 -68
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/aruba_freedom_patch.rb +0 -53
- data/features/support/env.rb +0 -50
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/lib/simplecov/jruby_fix.rb +0 -42
- data/lib/simplecov/railtie.rb +0 -7
- data/lib/simplecov/railties/tasks.rake +0 -11
- data/lib/simplecov/raw_coverage.rb +0 -39
- data/simplecov.gemspec +0 -27
- data/spec/1_8_fallbacks_spec.rb +0 -31
- data/spec/command_guesser_spec.rb +0 -48
- data/spec/config_loader_spec.rb +0 -14
- data/spec/configuration_spec.rb +0 -35
- data/spec/defaults_spec.rb +0 -41
- data/spec/deleted_source_spec.rb +0 -12
- data/spec/faked_project/Gemfile +0 -6
- data/spec/faked_project/Rakefile +0 -8
- data/spec/faked_project/cucumber.yml +0 -13
- data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
- data/spec/faked_project/features/support/env.rb +0 -12
- data/spec/faked_project/features/test_stuff.feature +0 -6
- data/spec/faked_project/lib/faked_project.rb +0 -11
- data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
- data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
- data/spec/faked_project/spec/faked_spec.rb +0 -11
- data/spec/faked_project/spec/forking_spec.rb +0 -8
- data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
- data/spec/faked_project/spec/some_class_spec.rb +0 -13
- data/spec/faked_project/spec/spec_helper.rb +0 -11
- data/spec/faked_project/test/faked_test.rb +0 -11
- data/spec/faked_project/test/meta_magic_test.rb +0 -13
- data/spec/faked_project/test/some_class_test.rb +0 -15
- data/spec/faked_project/test/test_helper.rb +0 -12
- data/spec/file_list_spec.rb +0 -50
- data/spec/filters_spec.rb +0 -202
- data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
- data/spec/fixtures/app/models/user.rb +0 -10
- data/spec/fixtures/deleted_source_sample.rb +0 -15
- data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
- data/spec/fixtures/frameworks/rspec_good.rb +0 -9
- data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
- data/spec/fixtures/frameworks/testunit_good.rb +0 -9
- data/spec/fixtures/iso-8859.rb +0 -3
- data/spec/fixtures/never.rb +0 -2
- data/spec/fixtures/resultset1.rb +0 -4
- data/spec/fixtures/resultset2.rb +0 -4
- data/spec/fixtures/sample.rb +0 -16
- data/spec/fixtures/skipped.rb +0 -4
- data/spec/fixtures/skipped_and_executed.rb +0 -8
- data/spec/fixtures/utf-8.rb +0 -3
- data/spec/helper.rb +0 -26
- data/spec/last_run_spec.rb +0 -48
- data/spec/lines_classifier_spec.rb +0 -103
- data/spec/multi_formatter_spec.rb +0 -20
- data/spec/raw_coverage_spec.rb +0 -92
- data/spec/result_merger_spec.rb +0 -171
- data/spec/result_spec.rb +0 -209
- data/spec/return_codes_spec.rb +0 -34
- data/spec/simplecov_spec.rb +0 -109
- data/spec/source_file_line_spec.rb +0 -155
- data/spec/source_file_spec.rb +0 -145
- data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
@@ -1,44 +0,0 @@
|
|
1
|
-
module GroupHelpers
|
2
|
-
def available_groups
|
3
|
-
all("#content .file_list_container")
|
4
|
-
end
|
5
|
-
|
6
|
-
def available_source_files
|
7
|
-
all(".source_files .source_table")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
World(GroupHelpers)
|
11
|
-
|
12
|
-
Then /^I should see the groups:$/ do |table|
|
13
|
-
expected_groups = table.hashes
|
14
|
-
# Given group names should be the same number than those rendered in report
|
15
|
-
expect(expected_groups.count).to eq(available_groups.count)
|
16
|
-
|
17
|
-
# Verify each of the expected groups has a file list container and corresponding title and coverage number
|
18
|
-
# as well as the correct number of links to files.
|
19
|
-
expected_groups.each do |group|
|
20
|
-
with_scope "#content ##{group['name'].gsub(/[^a-z]/i, '')}.file_list_container" do
|
21
|
-
file_count_in_group = page.all("a.src_link").count
|
22
|
-
expect(file_count_in_group).to eq(group["files"].to_i)
|
23
|
-
|
24
|
-
with_scope "h2" do
|
25
|
-
expect(page).to have_content(group["name"])
|
26
|
-
expect(page).to have_content(group["coverage"])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^I should see the source files:$/ do |table|
|
33
|
-
expected_files = table.hashes
|
34
|
-
expect(expected_files.length).to eq(available_source_files.count)
|
35
|
-
|
36
|
-
# Find all filenames and their coverage present in coverage report
|
37
|
-
files = available_source_files.map { |f| {"name" => f.find("h3").text, "coverage" => f.find("h4 > span").text} }
|
38
|
-
|
39
|
-
expect(files.sort_by { |hsh| hsh["name"] }).to eq(expected_files.sort_by { |hsh| hsh["name"] })
|
40
|
-
end
|
41
|
-
|
42
|
-
Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
|
43
|
-
expect(all(".source_table ol li.skipped").count).to eq(expected_count.to_i)
|
44
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# Just a shortcut to make framework setup more readable
|
2
|
-
# The test project is using separate config files to avoid specifying all of
|
3
|
-
# test/spec_helper in the features every time.
|
4
|
-
Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
|
5
|
-
framework_dir = begin
|
6
|
-
case framework
|
7
|
-
when /RSpec/i
|
8
|
-
"spec"
|
9
|
-
when /Test\/Unit/i
|
10
|
-
"test"
|
11
|
-
when /Cucumber/i
|
12
|
-
"features/support"
|
13
|
-
else
|
14
|
-
raise ArgumentError, "Could not identify test framework #{framework}!"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
steps %(
|
19
|
-
Given a file named "#{framework_dir}/simplecov_config.rb" with:
|
20
|
-
"""
|
21
|
-
#{config_body}
|
22
|
-
"""
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
|
27
|
-
steps %(
|
28
|
-
When I successfully run `#{command}`
|
29
|
-
Then a coverage report should have been generated
|
30
|
-
When I open the coverage report
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
Then /^a coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
35
|
-
coverage_dir ||= "coverage"
|
36
|
-
steps %(
|
37
|
-
Then the output should contain "Coverage report generated"
|
38
|
-
And a directory named "#{coverage_dir}" should exist
|
39
|
-
And the following files should exist:
|
40
|
-
| #{coverage_dir}/index.html |
|
41
|
-
| #{coverage_dir}/.resultset.json |
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
46
|
-
coverage_dir ||= "coverage"
|
47
|
-
steps %(
|
48
|
-
Then the output should not contain "Coverage report generated"
|
49
|
-
And a directory named "#{coverage_dir}" should not exist
|
50
|
-
And the following files should not exist:
|
51
|
-
| #{coverage_dir}/index.html |
|
52
|
-
| #{coverage_dir}/.resultset.json |
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
Then /^the report should be based upon:$/ do |table|
|
57
|
-
frameworks = table.raw.flatten
|
58
|
-
steps %(
|
59
|
-
Then the output should contain "Coverage report generated for #{frameworks.join(', ')}"
|
60
|
-
And I should see "using #{frameworks.join(', ')}" within "#footer"
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
# This is necessary to ensure timing-dependant tests like the merge timeout
|
65
|
-
# do not fail on powerful machines.
|
66
|
-
When /^I wait for (\d+) seconds$/ do |seconds|
|
67
|
-
sleep seconds.to_i
|
68
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Enforce the alphabetical execution of specs because rspec 2+ executes them
|
3
|
-
# randomly with `rspec spec` while we need them in an accurate order for coverage
|
4
|
-
# reports that include the spec files.
|
5
|
-
#
|
6
|
-
# This is due to the fact that coverage will not include the first loaded spec/test file.
|
7
|
-
# To get predictable coverage results, we need to know which one that is...
|
8
|
-
#
|
9
|
-
Transform "bundle exec rspec spec" do |_|
|
10
|
-
files = nil # Avoid shadowing
|
11
|
-
cd(".") { files = Dir["spec/**/*_spec.rb"] }
|
12
|
-
"bundle exec rspec #{files.sort.join(' ')}"
|
13
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module WithinHelpers
|
2
|
-
def with_scope(locator)
|
3
|
-
locator ? within(locator) { yield } : yield
|
4
|
-
end
|
5
|
-
end
|
6
|
-
World(WithinHelpers)
|
7
|
-
|
8
|
-
When /^I open the coverage report$/ do
|
9
|
-
visit "/"
|
10
|
-
end
|
11
|
-
|
12
|
-
Given /^(?:|I )am on (.+)$/ do |path|
|
13
|
-
visit path
|
14
|
-
end
|
15
|
-
|
16
|
-
When /^(?:|I )go to (.+)$/ do |path|
|
17
|
-
visit path
|
18
|
-
end
|
19
|
-
|
20
|
-
When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
|
21
|
-
with_scope(selector) do
|
22
|
-
click_button(button)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
|
27
|
-
with_scope(selector) do
|
28
|
-
click_link(link)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
33
|
-
with_scope(selector) do
|
34
|
-
expect(page).to have_content(text)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
39
|
-
regexp = Regexp.new(regexp)
|
40
|
-
with_scope(selector) do
|
41
|
-
expect(page).to have_xpath("//*", :text => regexp)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
|
46
|
-
with_scope(selector) do
|
47
|
-
expect(page).to have_no_content(text)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
52
|
-
regexp = Regexp.new(regexp)
|
53
|
-
with_scope(selector) do
|
54
|
-
expect(page).to have_no_xpath("//*", :text => regexp)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
Then /^show me the page$/ do
|
59
|
-
save_and_open_page # rubocop:disable Lint/Debugger
|
60
|
-
end
|
61
|
-
|
62
|
-
Then /^print the page$/ do
|
63
|
-
puts page.body
|
64
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# Freedom patch because of not working absolute directories, see: https://github.com/cucumber/aruba/issues/478
|
2
|
-
# code taken directly from aruba 0.14.2 - roughly here: https://github.com/cucumber/aruba/blob/master/lib/aruba/api/core.rb#L122-L159
|
3
|
-
# rubocop:disable all
|
4
|
-
module Aruba
|
5
|
-
module Api
|
6
|
-
module Core
|
7
|
-
def expand_path(file_name, dir_string = nil)
|
8
|
-
# only line added, don't ask why but I couldn't get alias_method to work...
|
9
|
-
return file_name if absolute?(file_name)
|
10
|
-
check_for_deprecated_variables if Aruba::VERSION < '1'
|
11
|
-
|
12
|
-
message = %(Filename "#{file_name}" needs to be a string. It cannot be nil or empty either. Please use `expand_path('.')` if you want the current directory to be expanded.)
|
13
|
-
|
14
|
-
fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
|
15
|
-
|
16
|
-
aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
|
17
|
-
|
18
|
-
if RUBY_VERSION < '1.9'
|
19
|
-
prefix = file_name.chars.to_a[0].to_s
|
20
|
-
rest = if file_name.chars.to_a[2..-1].nil?
|
21
|
-
nil
|
22
|
-
else
|
23
|
-
file_name.chars.to_a[2..-1].join
|
24
|
-
end
|
25
|
-
else
|
26
|
-
prefix = file_name[0]
|
27
|
-
rest = file_name[2..-1]
|
28
|
-
end
|
29
|
-
|
30
|
-
if aruba.config.fixtures_path_prefix == prefix
|
31
|
-
path = File.join(*[aruba.fixtures_directory, rest].compact)
|
32
|
-
|
33
|
-
fail ArgumentError, %(Fixture "#{rest}" does not exist in fixtures directory "#{aruba.fixtures_directory}". This was the one we found first on your system from all possible candidates: #{aruba.config.fixtures_directories.map { |p| format('"%s"', p) }.join(', ')}.) unless Aruba.platform.exist? path
|
34
|
-
|
35
|
-
path
|
36
|
-
elsif '~' == prefix
|
37
|
-
path = with_environment do
|
38
|
-
ArubaPath.new(File.expand_path(file_name))
|
39
|
-
end
|
40
|
-
|
41
|
-
fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path.to_s == '/'
|
42
|
-
fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless path.absolute?
|
43
|
-
|
44
|
-
path.to_s
|
45
|
-
else
|
46
|
-
directory = File.join(aruba.root_directory, aruba.current_directory)
|
47
|
-
ArubaPath.new(File.join(*[directory, dir_string, file_name].compact)).expand_path.to_s
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
# rubocop:enable all
|
data/features/support/env.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
if RUBY_VERSION < "1.9"
|
2
|
-
$stderr.puts "Sorry, Cucumber features are only meant to run on Ruby 1.9+ :("
|
3
|
-
exit 0
|
4
|
-
end
|
5
|
-
|
6
|
-
require "bundler"
|
7
|
-
Bundler.setup
|
8
|
-
require "aruba/cucumber"
|
9
|
-
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
|
10
|
-
require_relative "aruba_freedom_patch"
|
11
|
-
require "capybara/cucumber"
|
12
|
-
require "phantomjs/poltergeist"
|
13
|
-
|
14
|
-
# Fake rack app for capybara that just returns the latest coverage report from aruba temp project dir
|
15
|
-
Capybara.app = lambda { |env|
|
16
|
-
request_path = env["REQUEST_PATH"] || "/"
|
17
|
-
request_path = "/index.html" if request_path == "/"
|
18
|
-
[
|
19
|
-
200,
|
20
|
-
{"Content-Type" => "text/html"},
|
21
|
-
[File.read(File.join(File.dirname(__FILE__), "../../tmp/aruba/project/coverage", request_path))],
|
22
|
-
]
|
23
|
-
}
|
24
|
-
|
25
|
-
Capybara.default_driver = Capybara.javascript_driver = :poltergeist
|
26
|
-
|
27
|
-
Capybara.configure do |config|
|
28
|
-
config.ignore_hidden_elements = false
|
29
|
-
end
|
30
|
-
|
31
|
-
Before do
|
32
|
-
# JRuby takes it's time... See https://github.com/cucumber/aruba/issues/134
|
33
|
-
@aruba_timeout_seconds = RUBY_ENGINE == "jruby" ? 60 : 20
|
34
|
-
|
35
|
-
this_dir = File.dirname(__FILE__)
|
36
|
-
|
37
|
-
# Clean up and create blank state for fake project
|
38
|
-
cd(".") do
|
39
|
-
FileUtils.rm_rf "project"
|
40
|
-
FileUtils.cp_r File.join(this_dir, "../../spec/faked_project/"), "project"
|
41
|
-
end
|
42
|
-
|
43
|
-
step 'I cd to "project"'
|
44
|
-
end
|
45
|
-
|
46
|
-
# Workaround for https://github.com/cucumber/aruba/pull/125
|
47
|
-
Aruba.configure do |config|
|
48
|
-
config.exit_timeout = RUBY_ENGINE == "jruby" ? 60 : 20
|
49
|
-
config.command_runtime_environment = {"JRUBY_OPTS" => "--dev --debug"}
|
50
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
@test_unit
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Simply adding the basic simplecov lines to a project should get
|
5
|
-
the user a coverage report after running `rake test`
|
6
|
-
|
7
|
-
Scenario:
|
8
|
-
Given SimpleCov for Test/Unit is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start
|
12
|
-
"""
|
13
|
-
|
14
|
-
When I open the coverage report generated with `bundle exec rake test`
|
15
|
-
Then I should see the groups:
|
16
|
-
| name | coverage | files |
|
17
|
-
| All Files | 91.38% | 6 |
|
18
|
-
|
19
|
-
And I should see the source files:
|
20
|
-
| name | coverage |
|
21
|
-
| lib/faked_project.rb | 100.0 % |
|
22
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
23
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
24
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
25
|
-
| test/meta_magic_test.rb | 100.0 % |
|
26
|
-
| test/some_class_test.rb | 100.0 % |
|
27
|
-
|
28
|
-
# Note: faked_test.rb is not appearing here since that's the first unit test file
|
29
|
-
# loaded by Rake, and only there test_helper is required, which then loads simplecov
|
30
|
-
# and triggers tracking of all other loaded files! Solution for this would be to
|
31
|
-
# configure simplecov in this first test instead of test_helper.
|
32
|
-
|
33
|
-
And the report should be based upon:
|
34
|
-
| Unit Tests |
|
@@ -1,29 +0,0 @@
|
|
1
|
-
@test_unit
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Defining some groups and filters should give a corresponding
|
5
|
-
coverage report that respects those settings after running tests
|
6
|
-
|
7
|
-
Scenario:
|
8
|
-
Given SimpleCov for Test/Unit is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start do
|
12
|
-
add_group 'Libs', 'lib/faked_project/'
|
13
|
-
add_filter '/test/'
|
14
|
-
end
|
15
|
-
"""
|
16
|
-
|
17
|
-
When I open the coverage report generated with `bundle exec rake test`
|
18
|
-
Then I should see the groups:
|
19
|
-
| name | coverage | files |
|
20
|
-
| All Files | 88.1% | 4 |
|
21
|
-
| Libs | 86.11% | 3 |
|
22
|
-
| Ungrouped | 100.0% | 1 |
|
23
|
-
|
24
|
-
And I should see the source files:
|
25
|
-
| name | coverage |
|
26
|
-
| lib/faked_project.rb | 100.0 % |
|
27
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
28
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
29
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
@@ -1,35 +0,0 @@
|
|
1
|
-
@test_unit
|
2
|
-
Feature: Sophisticated grouping and filtering on Test/Unit
|
3
|
-
|
4
|
-
Defining groups and filters can be done by passing blocks or strings.
|
5
|
-
Blocks get each SimpleCov::SourceFile instance passed an can use arbitrary
|
6
|
-
and potentially weird conditions to remove files from the report or add them
|
7
|
-
to specific groups.
|
8
|
-
|
9
|
-
Scenario:
|
10
|
-
Given SimpleCov for Test/Unit is configured with:
|
11
|
-
"""
|
12
|
-
require 'simplecov'
|
13
|
-
SimpleCov.start do
|
14
|
-
add_group 'By block' do |src_file|
|
15
|
-
src_file.filename =~ /MaGiC/i
|
16
|
-
end
|
17
|
-
add_group 'By string', 'project/meta_magic'
|
18
|
-
|
19
|
-
add_filter 'faked_project.rb'
|
20
|
-
# Remove all files that include "describe" in their source
|
21
|
-
add_filter {|src_file| src_file.lines.any? {|line| line.src =~ /TestCase/ } }
|
22
|
-
add_filter {|src_file| src_file.covered_percent < 100 }
|
23
|
-
end
|
24
|
-
"""
|
25
|
-
|
26
|
-
When I open the coverage report generated with `bundle exec rake test`
|
27
|
-
Then I should see the groups:
|
28
|
-
| name | coverage | files |
|
29
|
-
| All Files | 100.0% | 1 |
|
30
|
-
| By block | 100.0% | 1 |
|
31
|
-
| By string | 100.0% | 1 |
|
32
|
-
|
33
|
-
And I should see the source files:
|
34
|
-
| name | coverage |
|
35
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
@@ -1,40 +0,0 @@
|
|
1
|
-
@test_unit
|
2
|
-
Feature: Grouping on Test/Unit using a custom filter class
|
3
|
-
|
4
|
-
Next to passing a block or a string to define a group, you can also pass
|
5
|
-
a filter class. The filter class inherits from SimpleCov::Filter and
|
6
|
-
must implement the matches? method, which is used to determine whether
|
7
|
-
or not a file should be added to the group.
|
8
|
-
|
9
|
-
Scenario:
|
10
|
-
Given SimpleCov for Test/Unit is configured with:
|
11
|
-
"""
|
12
|
-
require 'simplecov'
|
13
|
-
class CoverageFilter < SimpleCov::Filter
|
14
|
-
def matches?(source_file)
|
15
|
-
source_file.covered_percent < filter_argument
|
16
|
-
end
|
17
|
-
end
|
18
|
-
SimpleCov.start do
|
19
|
-
add_group 'By filter class', CoverageFilter.new(90)
|
20
|
-
add_group 'By string', 'project/meta_magic'
|
21
|
-
end
|
22
|
-
"""
|
23
|
-
|
24
|
-
When I open the coverage report generated with `bundle exec rake test`
|
25
|
-
Then I should see the groups:
|
26
|
-
| name | coverage | files |
|
27
|
-
| All Files | 91.38% | 6 |
|
28
|
-
| By filter class | 78.26% | 2 |
|
29
|
-
| By string | 100.0% | 1 |
|
30
|
-
| Ungrouped | 100.0% | 3 |
|
31
|
-
|
32
|
-
And I should see the source files:
|
33
|
-
| name | coverage |
|
34
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
35
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
36
|
-
| lib/faked_project.rb | 100.0 % |
|
37
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
38
|
-
| test/meta_magic_test.rb | 100.0 % |
|
39
|
-
| test/some_class_test.rb | 100.0 % |
|
40
|
-
|