simplecov 0.6.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +163 -80
- data/LICENSE +1 -1
- data/README.md +776 -277
- data/doc/alternate-formatters.md +71 -0
- data/doc/commercial-services.md +25 -0
- data/doc/editor-integration.md +18 -0
- data/lib/minitest/simplecov_plugin.rb +15 -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/combine.rb +30 -0
- data/lib/simplecov/command_guesser.rb +53 -38
- data/lib/simplecov/configuration.rb +478 -193
- data/lib/simplecov/coverage_statistics.rb +56 -0
- data/lib/simplecov/default_formatter.rb +20 -0
- data/lib/simplecov/defaults.rb +40 -44
- data/lib/simplecov/exit_codes/exit_code_handling.rb +29 -0
- data/lib/simplecov/exit_codes/maximum_coverage_drop_check.rb +83 -0
- data/lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb +54 -0
- data/lib/simplecov/exit_codes/minimum_overall_coverage_check.rb +53 -0
- data/lib/simplecov/exit_codes.rb +15 -0
- data/lib/simplecov/file_list.rb +112 -36
- data/lib/simplecov/filter.rb +54 -4
- data/lib/simplecov/formatter/multi_formatter.rb +32 -0
- data/lib/simplecov/formatter/simple_formatter.rb +21 -15
- data/lib/simplecov/formatter.rb +4 -1
- data/lib/simplecov/last_run.rb +28 -0
- data/lib/simplecov/lines_classifier.rb +48 -0
- data/lib/simplecov/load_global_config.rb +8 -0
- data/lib/simplecov/no_defaults.rb +4 -0
- data/lib/simplecov/process.rb +19 -0
- 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/profiles.rb +35 -0
- data/lib/simplecov/result.rb +33 -64
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +178 -64
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/source_file.rb +304 -123
- data/lib/simplecov/useless_results_remover.rb +18 -0
- data/lib/simplecov/version.rb +4 -2
- data/lib/simplecov.rb +396 -49
- metadata +81 -242
- data/.gitignore +0 -30
- data/.rvmrc +0 -1
- data/.travis.yml +0 -13
- data/Gemfile +0 -9
- data/Rakefile +0 -16
- data/cucumber.yml +0 -13
- data/features/config_adapters.feature +0 -44
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -33
- data/features/config_coverage_dir.feature +0 -20
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_merge_timeout.feature +0 -38
- data/features/config_nocov_token.feature +0 -79
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -93
- data/features/cucumber_basic.feature +0 -29
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/rspec_basic.feature +0 -31
- 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 -35
- data/features/rspec_groups_using_filter_class.feature +0 -40
- 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 -45
- data/features/step_definitions/simplecov_steps.rb +0 -61
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/env.rb +0 -26
- 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/adapters.rb +0 -29
- data/lib/simplecov/merge_helpers.rb +0 -39
- data/lib/simplecov/railtie.rb +0 -7
- data/lib/simplecov/railties/tasks.rake +0 -11
- data/simplecov.gemspec +0 -28
- data/test/faked_project/Gemfile +0 -6
- data/test/faked_project/Rakefile +0 -8
- data/test/faked_project/cucumber.yml +0 -13
- data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
- data/test/faked_project/features/support/env.rb +0 -12
- data/test/faked_project/features/test_stuff.feature +0 -6
- data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/test/faked_project/lib/faked_project/some_class.rb +0 -29
- data/test/faked_project/lib/faked_project.rb +0 -11
- data/test/faked_project/spec/faked_spec.rb +0 -11
- data/test/faked_project/spec/meta_magic_spec.rb +0 -10
- data/test/faked_project/spec/some_class_spec.rb +0 -10
- data/test/faked_project/spec/spec_helper.rb +0 -15
- data/test/faked_project/test/faked_test.rb +0 -11
- data/test/faked_project/test/meta_magic_test.rb +0 -13
- data/test/faked_project/test/some_class_test.rb +0 -15
- data/test/faked_project/test/test_helper.rb +0 -16
- data/test/fixtures/app/controllers/sample_controller.rb +0 -10
- data/test/fixtures/app/models/user.rb +0 -10
- data/test/fixtures/deleted_source_sample.rb +0 -15
- data/test/fixtures/frameworks/rspec_bad.rb +0 -9
- data/test/fixtures/frameworks/rspec_good.rb +0 -9
- data/test/fixtures/frameworks/testunit_bad.rb +0 -9
- data/test/fixtures/frameworks/testunit_good.rb +0 -9
- data/test/fixtures/resultset1.rb +0 -4
- data/test/fixtures/resultset2.rb +0 -5
- data/test/fixtures/sample.rb +0 -16
- data/test/fixtures/utf-8.rb +0 -3
- data/test/helper.rb +0 -35
- data/test/shoulda_macros.rb +0 -29
- data/test/test_1_8_fallbacks.rb +0 -33
- data/test/test_command_guesser.rb +0 -21
- data/test/test_deleted_source.rb +0 -16
- data/test/test_file_list.rb +0 -24
- data/test/test_filters.rb +0 -80
- data/test/test_merge_helpers.rb +0 -107
- data/test/test_result.rb +0 -147
- data/test/test_return_codes.rb +0 -39
- data/test/test_source_file.rb +0 -86
- data/test/test_source_file_line.rb +0 -110
@@ -1,38 +0,0 @@
|
|
1
|
-
@test_unit @rspec @merging @config
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
The maximum time between resultset merges can be customized
|
5
|
-
using SimpleCov.merge_timeout SECONDS. This can be helpful for
|
6
|
-
long-running test-suites that fail to merge because of the time
|
7
|
-
between individual suite finishes is more then the default timeout
|
8
|
-
of 10 minutes.
|
9
|
-
|
10
|
-
Here, for the sake of testing the opposite case is shown, choosing
|
11
|
-
a merge timeout so short that the first test suite's results actually
|
12
|
-
are out of date when the second suite finishes and thus does not end up
|
13
|
-
in the report.
|
14
|
-
|
15
|
-
Scenario:
|
16
|
-
Given SimpleCov for Test/Unit is configured with:
|
17
|
-
"""
|
18
|
-
require 'simplecov'
|
19
|
-
SimpleCov.start do
|
20
|
-
merge_timeout 1
|
21
|
-
end
|
22
|
-
"""
|
23
|
-
Given SimpleCov for RSpec is configured with:
|
24
|
-
"""
|
25
|
-
require 'simplecov'
|
26
|
-
SimpleCov.start do
|
27
|
-
merge_timeout 1
|
28
|
-
end
|
29
|
-
"""
|
30
|
-
|
31
|
-
When I open the coverage report generated with `bundle exec rake test`
|
32
|
-
Then the report should be based upon:
|
33
|
-
| Unit Tests |
|
34
|
-
|
35
|
-
When I open the coverage report generated with `bundle exec rspec spec`
|
36
|
-
Then the report should be based upon:
|
37
|
-
| RSpec |
|
38
|
-
|
@@ -1,79 +0,0 @@
|
|
1
|
-
@test_unit @nocov
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Code wrapped in # :nocov: will be ignored by coverage reports.
|
5
|
-
The name of the token can be configured with SimpleCov.nocov_token or SimpleCov.skip_token
|
6
|
-
|
7
|
-
Scenario: Custom nocov token using nocov_token
|
8
|
-
Given SimpleCov for Test/Unit is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start 'test_frameworks' do
|
12
|
-
nocov_token 'skippit'
|
13
|
-
end
|
14
|
-
"""
|
15
|
-
|
16
|
-
Given a file named "lib/faked_project/nocov.rb" with:
|
17
|
-
"""
|
18
|
-
class SourceCodeWithNocov
|
19
|
-
# :skippit:
|
20
|
-
def some_weird_code
|
21
|
-
never_reached
|
22
|
-
rescue => err
|
23
|
-
but no one cares about invalid ruby here
|
24
|
-
end
|
25
|
-
# :skippit:
|
26
|
-
end
|
27
|
-
"""
|
28
|
-
|
29
|
-
When I open the coverage report generated with `bundle exec rake test`
|
30
|
-
|
31
|
-
Then I should see the source files:
|
32
|
-
| name | coverage |
|
33
|
-
| lib/faked_project.rb | 100.0 % |
|
34
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
35
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
36
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
37
|
-
| lib/faked_project/nocov.rb | 100.0 % |
|
38
|
-
|
39
|
-
And there should be 5 skipped lines in the source files
|
40
|
-
|
41
|
-
And the report should be based upon:
|
42
|
-
| Unit Tests |
|
43
|
-
|
44
|
-
Scenario: Custom nocov token using skip_token
|
45
|
-
Given SimpleCov for Test/Unit is configured with:
|
46
|
-
"""
|
47
|
-
require 'simplecov'
|
48
|
-
SimpleCov.start 'test_frameworks' do
|
49
|
-
skip_token 'skippit'
|
50
|
-
end
|
51
|
-
"""
|
52
|
-
|
53
|
-
Given a file named "lib/faked_project/nocov.rb" with:
|
54
|
-
"""
|
55
|
-
class SourceCodeWithNocov
|
56
|
-
# :skippit:
|
57
|
-
def some_weird_code
|
58
|
-
never_reached
|
59
|
-
rescue => err
|
60
|
-
but no one cares about invalid ruby here
|
61
|
-
end
|
62
|
-
# :skippit:
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
|
66
|
-
When I open the coverage report generated with `bundle exec rake test`
|
67
|
-
|
68
|
-
Then I should see the source files:
|
69
|
-
| name | coverage |
|
70
|
-
| lib/faked_project.rb | 100.0 % |
|
71
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
72
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
73
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
74
|
-
| lib/faked_project/nocov.rb | 100.0 % |
|
75
|
-
|
76
|
-
And there should be 5 skipped lines in the source files
|
77
|
-
|
78
|
-
And the report should be based upon:
|
79
|
-
| Unit Tests |
|
@@ -1,27 +0,0 @@
|
|
1
|
-
@test_unit @config
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
SimpleCov guesses the project name from the project root dir's name.
|
5
|
-
If this is not sufficient for you, you can specify a custom name using
|
6
|
-
SimpleCov.project_name('xyz')
|
7
|
-
|
8
|
-
|
9
|
-
Scenario: Guessed name
|
10
|
-
Given SimpleCov for Test/Unit is configured with:
|
11
|
-
"""
|
12
|
-
require 'simplecov'
|
13
|
-
SimpleCov.start
|
14
|
-
"""
|
15
|
-
|
16
|
-
When I open the coverage report generated with `bundle exec rake test`
|
17
|
-
Then I should see "Code coverage for Project"
|
18
|
-
|
19
|
-
Scenario: Custom name
|
20
|
-
Given SimpleCov for Test/Unit is configured with:
|
21
|
-
"""
|
22
|
-
require 'simplecov'
|
23
|
-
SimpleCov.start { project_name "Superfancy 2.0" }
|
24
|
-
"""
|
25
|
-
|
26
|
-
When I open the coverage report generated with `bundle exec rake test`
|
27
|
-
Then I should see "Code coverage for Superfancy 2.0"
|
@@ -1,93 +0,0 @@
|
|
1
|
-
@test_unit @config
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
There's several ways to configure SimpleCov. All of those
|
5
|
-
config schemes below are equivalent and can be chosen by personal
|
6
|
-
preference or project requirements.
|
7
|
-
|
8
|
-
Background:
|
9
|
-
Given SimpleCov for Test/Unit is configured with:
|
10
|
-
"""
|
11
|
-
require 'simplecov'
|
12
|
-
"""
|
13
|
-
|
14
|
-
Scenario: Inside start block
|
15
|
-
Given a file named ".simplecov" with:
|
16
|
-
"""
|
17
|
-
SimpleCov.start do
|
18
|
-
add_filter 'test'
|
19
|
-
command_name 'Config Test Runner'
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
|
23
|
-
When I open the coverage report generated with `bundle exec rake test`
|
24
|
-
Then I should see "4 files in total."
|
25
|
-
And I should see "using Config Test Runner" within "#footer"
|
26
|
-
|
27
|
-
Scenario: Explicitly before start block
|
28
|
-
Given a file named ".simplecov" with:
|
29
|
-
"""
|
30
|
-
SimpleCov.add_filter 'test'
|
31
|
-
SimpleCov.command_name 'Config Test Runner'
|
32
|
-
SimpleCov.start
|
33
|
-
"""
|
34
|
-
|
35
|
-
When I open the coverage report generated with `bundle exec rake test`
|
36
|
-
Then I should see "4 files in total."
|
37
|
-
And I should see "using Config Test Runner" within "#footer"
|
38
|
-
|
39
|
-
Scenario: Explicitly after start block
|
40
|
-
Given a file named ".simplecov" with:
|
41
|
-
"""
|
42
|
-
SimpleCov.start
|
43
|
-
SimpleCov.add_filter 'test'
|
44
|
-
SimpleCov.command_name 'Config Test Runner'
|
45
|
-
"""
|
46
|
-
|
47
|
-
When I open the coverage report generated with `bundle exec rake test`
|
48
|
-
Then I should see "4 files in total."
|
49
|
-
And I should see "using Config Test Runner" within "#footer"
|
50
|
-
|
51
|
-
Scenario: Using configure block after start
|
52
|
-
Given a file named ".simplecov" with:
|
53
|
-
"""
|
54
|
-
SimpleCov.start
|
55
|
-
SimpleCov.configure do
|
56
|
-
add_filter 'test'
|
57
|
-
command_name 'Config Test Runner'
|
58
|
-
end
|
59
|
-
"""
|
60
|
-
|
61
|
-
When I open the coverage report generated with `bundle exec rake test`
|
62
|
-
Then I should see "4 files in total."
|
63
|
-
And I should see "using Config Test Runner" within "#footer"
|
64
|
-
|
65
|
-
Scenario: Using configure block before start
|
66
|
-
Given a file named ".simplecov" with:
|
67
|
-
"""
|
68
|
-
SimpleCov.configure do
|
69
|
-
add_filter 'test'
|
70
|
-
command_name 'Config Test Runner'
|
71
|
-
end
|
72
|
-
SimpleCov.start
|
73
|
-
"""
|
74
|
-
|
75
|
-
When I open the coverage report generated with `bundle exec rake test`
|
76
|
-
Then I should see "4 files in total."
|
77
|
-
And I should see "using Config Test Runner" within "#footer"
|
78
|
-
|
79
|
-
Scenario: Mixing configure and start block config
|
80
|
-
Given a file named ".simplecov" with:
|
81
|
-
"""
|
82
|
-
SimpleCov.configure do
|
83
|
-
command_name 'Config Test Runner'
|
84
|
-
end
|
85
|
-
SimpleCov.start do
|
86
|
-
add_filter 'test'
|
87
|
-
end
|
88
|
-
"""
|
89
|
-
|
90
|
-
When I open the coverage report generated with `bundle exec rake test`
|
91
|
-
Then I should see "4 files in total."
|
92
|
-
And I should see "using Config Test Runner" within "#footer"
|
93
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
@cucumber
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Simply adding the basic simplecov lines to a project should get
|
5
|
-
the user a coverage report after running `cucumber features`
|
6
|
-
|
7
|
-
Scenario:
|
8
|
-
Given SimpleCov for Cucumber is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start
|
12
|
-
"""
|
13
|
-
|
14
|
-
When I open the coverage report generated with `bundle exec cucumber features`
|
15
|
-
Then I should see the groups:
|
16
|
-
| name | coverage | files |
|
17
|
-
| All Files | 91.23% | 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
|
-
| features/step_definitions/my_steps.rb | 100.0 % |
|
26
|
-
| features/support/simplecov_config.rb | 100.0 % |
|
27
|
-
|
28
|
-
And the report should be based upon:
|
29
|
-
| Cucumber Features |
|
@@ -1,44 +0,0 @@
|
|
1
|
-
@test_unit @rspec @merging
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Test suites like RSpec and Test/Unit should be merged automatically
|
5
|
-
when both have been run recently. The coverage report will feature
|
6
|
-
the joined results of all test suites that are using SimpleCov.
|
7
|
-
|
8
|
-
Scenario:
|
9
|
-
Given SimpleCov for Test/Unit is configured with:
|
10
|
-
"""
|
11
|
-
require 'simplecov'
|
12
|
-
SimpleCov.start do
|
13
|
-
add_filter 'test.rb'
|
14
|
-
add_filter 'spec.rb'
|
15
|
-
end
|
16
|
-
"""
|
17
|
-
And SimpleCov for RSpec is configured with:
|
18
|
-
"""
|
19
|
-
require 'simplecov'
|
20
|
-
SimpleCov.start do
|
21
|
-
add_filter 'test.rb'
|
22
|
-
add_filter 'spec.rb'
|
23
|
-
end
|
24
|
-
"""
|
25
|
-
|
26
|
-
When I open the coverage report generated with `bundle exec rake test`
|
27
|
-
Then the report should be based upon:
|
28
|
-
| Unit Tests |
|
29
|
-
|
30
|
-
When I open the coverage report generated with `bundle exec rspec spec`
|
31
|
-
Then the report should be based upon:
|
32
|
-
| RSpec |
|
33
|
-
| Unit Tests |
|
34
|
-
|
35
|
-
And I should see the groups:
|
36
|
-
| name | coverage | files |
|
37
|
-
| All Files | 90.48% | 4 |
|
38
|
-
|
39
|
-
And I should see the source files:
|
40
|
-
| name | coverage |
|
41
|
-
| lib/faked_project.rb | 100.0 % |
|
42
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
43
|
-
| lib/faked_project/framework_specific.rb | 87.5 % |
|
44
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
@@ -1,31 +0,0 @@
|
|
1
|
-
@rspec
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Simply adding the basic simplecov lines to a project should get
|
5
|
-
the user a coverage report after running `rspec`
|
6
|
-
|
7
|
-
Scenario:
|
8
|
-
Given SimpleCov for RSpec is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start
|
12
|
-
"""
|
13
|
-
|
14
|
-
When I open the coverage report generated with `bundle exec rspec spec`
|
15
|
-
Then I should see the groups:
|
16
|
-
| name | coverage | files |
|
17
|
-
| All Files | 90.74% | 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
|
-
| spec/meta_magic_spec.rb | 100.0 % |
|
26
|
-
| spec/some_class_spec.rb | 100.0 % |
|
27
|
-
|
28
|
-
# Note: faked_spec.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.
|
@@ -1,14 +0,0 @@
|
|
1
|
-
@rspec
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Running specs with a failing rspec setup
|
5
|
-
|
6
|
-
Scenario: Fail if rspec fails before starting its tests
|
7
|
-
Given a file named "spec/spec_helper.rb" with:
|
8
|
-
"""
|
9
|
-
require 'simplecov'
|
10
|
-
SimpleCov.start
|
11
|
-
raise "some exception in the class loading before the tests start"
|
12
|
-
"""
|
13
|
-
When I run `bundle exec rspec spec`
|
14
|
-
Then the exit status should not be 0
|
@@ -1,29 +0,0 @@
|
|
1
|
-
@rspec
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Defining some groups and filters should give a corresponding
|
5
|
-
coverage report that respects those settings after running rspec
|
6
|
-
|
7
|
-
Scenario:
|
8
|
-
Given SimpleCov for RSpec is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start do
|
12
|
-
add_group 'Libs', 'lib/faked_project/'
|
13
|
-
add_filter '/spec/'
|
14
|
-
end
|
15
|
-
"""
|
16
|
-
|
17
|
-
When I open the coverage report generated with `bundle exec rspec spec`
|
18
|
-
And 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
|
-
@rspec
|
2
|
-
Feature: Sophisticated grouping and filtering on RSpec
|
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 RSpec 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 =~ /describe/ } }
|
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 rspec spec`
|
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
|
-
@rspec
|
2
|
-
Feature: Grouping on RSpec 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 RSpec 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 rspec spec`
|
25
|
-
Then I should see the groups:
|
26
|
-
| name | coverage | files |
|
27
|
-
| All Files | 90.74% | 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
|
-
| spec/meta_magic_spec.rb | 100.0 % |
|
39
|
-
| spec/some_class_spec.rb | 100.0 % |
|
40
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
@rspec
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
Running specs without simplecov configuration
|
5
|
-
|
6
|
-
Scenario: No config at all
|
7
|
-
When I successfully run `bundle exec rspec spec`
|
8
|
-
Then no coverage report should have been generated
|
9
|
-
|
10
|
-
Scenario: Configured, but not started
|
11
|
-
Given SimpleCov for RSpec is configured with:
|
12
|
-
"""
|
13
|
-
require 'simplecov'
|
14
|
-
SimpleCov.configure do
|
15
|
-
add_filter 'somefilter'
|
16
|
-
end
|
17
|
-
"""
|
18
|
-
|
19
|
-
When I successfully run `bundle exec rspec spec`
|
20
|
-
Then no coverage report should have been generated
|
@@ -1,70 +0,0 @@
|
|
1
|
-
@test_unit @nocov
|
2
|
-
Feature:
|
3
|
-
|
4
|
-
When code is wrapped in :nocov: comment blocks, it does not count
|
5
|
-
against the coverage numbers.
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given SimpleCov for Test/Unit is configured with:
|
9
|
-
"""
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start 'test_frameworks'
|
12
|
-
"""
|
13
|
-
|
14
|
-
Scenario: Plain run with a nocov'd method
|
15
|
-
Given a file named "lib/faked_project/nocov.rb" with:
|
16
|
-
"""
|
17
|
-
class SourceCodeWithNocov
|
18
|
-
#:nocov:
|
19
|
-
def some_weird_code
|
20
|
-
never_reached
|
21
|
-
rescue => err
|
22
|
-
but no one cares about invalid ruby here
|
23
|
-
end
|
24
|
-
#:nocov:
|
25
|
-
end
|
26
|
-
"""
|
27
|
-
|
28
|
-
When I open the coverage report generated with `bundle exec rake test`
|
29
|
-
|
30
|
-
Then I should see the source files:
|
31
|
-
| name | coverage |
|
32
|
-
| lib/faked_project.rb | 100.0 % |
|
33
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
34
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
35
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
36
|
-
| lib/faked_project/nocov.rb | 100.0 % |
|
37
|
-
|
38
|
-
And there should be 5 skipped lines in the source files
|
39
|
-
|
40
|
-
And the report should be based upon:
|
41
|
-
| Unit Tests |
|
42
|
-
|
43
|
-
Scenario: Number of spaces should not mix up nocov results
|
44
|
-
Given a file named "lib/faked_project/nocov.rb" with:
|
45
|
-
"""
|
46
|
-
class SourceCodeWithNocov
|
47
|
-
# :nocov:
|
48
|
-
def some_weird_code
|
49
|
-
never_reached
|
50
|
-
rescue => err
|
51
|
-
but no one cares about invalid ruby here
|
52
|
-
end
|
53
|
-
# :nocov:
|
54
|
-
end
|
55
|
-
"""
|
56
|
-
|
57
|
-
When I open the coverage report generated with `bundle exec rake test`
|
58
|
-
|
59
|
-
Then I should see the source files:
|
60
|
-
| name | coverage |
|
61
|
-
| lib/faked_project.rb | 100.0 % |
|
62
|
-
| lib/faked_project/some_class.rb | 80.0 % |
|
63
|
-
| lib/faked_project/framework_specific.rb | 75.0 % |
|
64
|
-
| lib/faked_project/meta_magic.rb | 100.0 % |
|
65
|
-
| lib/faked_project/nocov.rb | 100.0 % |
|
66
|
-
|
67
|
-
And there should be 5 skipped lines in the source files
|
68
|
-
|
69
|
-
And the report should be based upon:
|
70
|
-
| Unit Tests |
|
@@ -1,45 +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
|
-
|
13
|
-
Then /^I should see the groups:$/ do |table|
|
14
|
-
expected_groups = table.hashes
|
15
|
-
# Given group names should be the same number than those rendered in report
|
16
|
-
expected_groups.count.should == available_groups.count
|
17
|
-
|
18
|
-
# Verify each of the expected groups has a file list container and corresponding title and coverage number
|
19
|
-
# as well as the correct number of links to files.
|
20
|
-
expected_groups.each do |group|
|
21
|
-
with_scope "#content ##{group["name"].gsub(/[^a-z]/i, '')}.file_list_container" do
|
22
|
-
file_count_in_group = page.all('a.src_link').count
|
23
|
-
file_count_in_group.should == group["files"].to_i
|
24
|
-
|
25
|
-
with_scope "h2" do
|
26
|
-
page.should have_content(group["name"])
|
27
|
-
page.should have_content(group["coverage"])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Then /^I should see the source files:$/ do |table|
|
34
|
-
expected_files = table.hashes
|
35
|
-
expected_files.length.should == available_source_files.count
|
36
|
-
|
37
|
-
# Find all filenames and their coverage present in coverage report
|
38
|
-
files = available_source_files.map {|f| {"name" => f.find('h3').text, "coverage" => f.find('.header span').text} }
|
39
|
-
|
40
|
-
files.sort_by {|hsh| hsh["name"] }.should == expected_files.sort_by {|hsh| hsh["name"] }
|
41
|
-
end
|
42
|
-
|
43
|
-
Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
|
44
|
-
all(".source_table ol li.skipped").count.should == expected_count.to_i
|
45
|
-
end
|
@@ -1,61 +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 = case framework
|
6
|
-
when /RSpec/i
|
7
|
-
"spec"
|
8
|
-
when /Test\/Unit/i
|
9
|
-
"test"
|
10
|
-
when /Cucumber/i
|
11
|
-
"features/support"
|
12
|
-
else
|
13
|
-
raise ArgumentError, "Could not identify test framework #{framework}!"
|
14
|
-
end
|
15
|
-
|
16
|
-
steps %Q{
|
17
|
-
Given a file named "#{framework_dir}/simplecov_config.rb" with:
|
18
|
-
"""
|
19
|
-
#{config_body}
|
20
|
-
"""
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
|
25
|
-
steps %Q{
|
26
|
-
When I successfully run `#{command}`
|
27
|
-
Then a coverage report should have been generated
|
28
|
-
When I open the coverage report
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^a coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
33
|
-
coverage_dir ||= 'coverage'
|
34
|
-
steps %Q{
|
35
|
-
Then the output should contain "Coverage report generated"
|
36
|
-
And a directory named "#{coverage_dir}" should exist
|
37
|
-
And the following files should exist:
|
38
|
-
| #{coverage_dir}/index.html |
|
39
|
-
| #{coverage_dir}/.resultset.json |
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
44
|
-
coverage_dir ||= 'coverage'
|
45
|
-
steps %Q{
|
46
|
-
Then the output should not contain "Coverage report generated"
|
47
|
-
And a directory named "#{coverage_dir}" should not exist
|
48
|
-
And the following files should not exist:
|
49
|
-
| #{coverage_dir}/index.html |
|
50
|
-
| #{coverage_dir}/.resultset.json |
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
Then /^the report should be based upon:$/ do |table|
|
55
|
-
frameworks = table.raw.flatten
|
56
|
-
steps %Q{
|
57
|
-
Then the output should contain "Coverage report generated for #{frameworks.join(", ")}"
|
58
|
-
And I should see "using #{frameworks.join(", ")}" within "#footer"
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
@@ -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 |t|
|
10
|
-
files = nil # Avoid shadowing
|
11
|
-
in_current_dir { files = Dir['spec/**/*_spec.rb'] }
|
12
|
-
"bundle exec rspec #{files.sort.join(' ')}"
|
13
|
-
end
|