simplecov 0.15.1 → 0.18.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +74 -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 +205 -104
- data/doc/alternate-formatters.md +20 -0
- data/lib/simplecov.rb +246 -52
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +25 -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 +79 -8
- data/lib/simplecov/defaults.rb +12 -81
- 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 +4 -0
- 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 +23 -4
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +14 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +222 -110
- data/lib/simplecov/source_file/branch.rb +106 -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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd6ab6b1c33e8b2503dc00691a8ae500ae0caf885fc2dba52bbe102d696d926
|
4
|
+
data.tar.gz: 41c70724c0beb18bd66f665cb078a8b9cf95d1dbb770bf1eb0601156c12370e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1dcb50ce7ef6765a9f519bda006388d587c67cd103bcf6d0f4bd4d4427ebef240de13772e8925f62d70dd232310bd705b66fbda1c39c25444dcd329b9dedc1
|
7
|
+
data.tar.gz: cc1160ba31aa5ecdcb46a255e3147e78f649789d542d1363343fec803ec9c5c96759272990ba67ceb75a0a07116325f962a69354d8a01477a905b491bba86275
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,76 @@
|
|
1
|
+
0.18.0.beta1 (2020-01-05)
|
2
|
+
===================
|
3
|
+
|
4
|
+
This is a huge release highlighted by changing our support for ruby versions to 2.4+ (so things that aren't EOL'ed) and finally adding branch coverage support!
|
5
|
+
|
6
|
+
This release is still beta because we'd love for you to test out branch coverage and get your feedback before doing a full release.
|
7
|
+
|
8
|
+
On a personal note from [@PragTob](https://github.com/PragTob/) thanks to [ruby together](https://rubytogether.org/) for sponsoring this work on SimpleCov making it possible to deliver this and subsequent releases.
|
9
|
+
|
10
|
+
## Breaking
|
11
|
+
* Dropped official support for all EOL'ed rubies meaning we only officially support 2.4+ - older rubies might still work but are not guaranteed to do so. Older release should still work. (thanks [@deivid-rodriguez](https://github.com/deivid-rodriguez))
|
12
|
+
* Dropped the `rake simplecov` task that "magically" integreated with rails. It was always undocumented, caused some issues and [had some issues](https://github.com/colszowka/simplecov/issues/689#issuecomment-561572327). Use the integration as described in the README please :)
|
13
|
+
|
14
|
+
## Enhancements
|
15
|
+
|
16
|
+
* Branch coverage is here! Please try it out and test it! You can activate it with `enable_coverage :branch`. See the README for more details. This is thanks to a bunch of people most notably [@som4ik](https://github.com/som4ik), [@tycooon](https://github.com/tycooon), [@stepozer](https://github.com/stepozer), [@klyonrad](https://github.com/klyonrad) and your humble maintainers also contributed ;)
|
17
|
+
* If the minimum coverage is set to be greater than 100, a warning will be shown. See [#737](https://github.com/colszowka/simplecov/pull/737) (thanks [@belfazt](https://github.com/belfazt))
|
18
|
+
* Add a configuration option to disable the printing of non-successful exit statuses. See [#747](https://github.com/colszowka/simplecov/pull/746) (thanks [@JacobEvelyn](https://github.com/JacobEvelyn))
|
19
|
+
* Calculating 100% coverage is now stricter, so 100% means 100%. See [#680](https://github.com/colszowka/simplecov/pull/680) thanks [@gleseur](https://github.com/gleseur)
|
20
|
+
|
21
|
+
## Bugfixes
|
22
|
+
|
23
|
+
* Add new instance of `Minitest` constant. The `MiniTest` constant (with the capital T) will be removed in the next major release of Minitest. See [#757](https://github.com/colszowka/simplecov/pull/757) (thanks [@adam12](https://github.com/adam12))
|
24
|
+
|
25
|
+
0.17.1 (2019-09-16)
|
26
|
+
===================
|
27
|
+
|
28
|
+
Bugfix release for problems with ParallelTests.
|
29
|
+
|
30
|
+
## Bugfixes
|
31
|
+
|
32
|
+
* Avoid hanging with parallel_tests. See [#746](https://github.com/colszowka/simplecov/pull/746) (thanks [@annaswims](https://github.com/annaswims))
|
33
|
+
|
34
|
+
0.17.0 (2019-07-02)
|
35
|
+
===================
|
36
|
+
|
37
|
+
Maintenance release with nice convenience features and important bugfixes.
|
38
|
+
Notably this **will be the last release to support ruby versions that have reached their end of life**. Moving forward official CRuby support will be 2.4+ and JRuby support will be 9.2+. Older versions might still work but no guarantees.
|
39
|
+
|
40
|
+
## Enhancements
|
41
|
+
|
42
|
+
* Per default filter hidden files and folders. See [#721](https://github.com/colszowka/simplecov/pull/721) (thanks [Renuo AG](https://www.renuo.ch))
|
43
|
+
* Print the exit status explicitly when it's not a successful build so it's easier figure out SimpleCov failed the build in the output. See [#688](https://github.com/colszowka/simplecov/pull/688) (thanks [@daemonsy](https://github.com/daemonsy))
|
44
|
+
|
45
|
+
## Bugfixes
|
46
|
+
|
47
|
+
* Avoid a premature failure exit code when setting `minimum_coverage` in combination with using [parallel_tests](https://github.com/grosser/parallel_tests). See [#706](https://github.com/colszowka/simplecov/pull/706) (thanks [@f1sherman](https://github.com/f1sherman))
|
48
|
+
* Project roots with special characters no longer cause crashes. See [#717](https://github.com/colszowka/simplecov/pull/717) (thanks [@deivid-rodriguez](https://github.com/deivid-rodriguez))
|
49
|
+
* Avoid continously overriding test results with manual `ResultMergere.store_results` usage. See [#674](https://github.com/colszowka/simplecov/pull/674) (thanks [@tomeon](https://github.com/tomeon))
|
50
|
+
|
51
|
+
0.16.1 (2018-03-16)
|
52
|
+
===================
|
53
|
+
|
54
|
+
## Bugfixes
|
55
|
+
|
56
|
+
* Include the LICENSE in the distributed gem again (accidentally removed in 0.16.0). (thanks @tas50)
|
57
|
+
|
58
|
+
0.16.0 (2018-03-15)
|
59
|
+
===================
|
60
|
+
|
61
|
+
## Enhancements
|
62
|
+
|
63
|
+
* Relax version constraint on `docile`, per SemVer
|
64
|
+
* exception that occurred on exit is available as `exit_exception`! See [#639](https://github.com/colszowka/simplecov/pull/639) (thanks @thomas07vt)
|
65
|
+
* Performance: processing results now runs from 2.5x to 3.75x faster. See [#662](https://github.com/colszowka/simplecov/pull/662) (thanks @BMorearty & @eregon)
|
66
|
+
* Decrease gem size by only shipping lib and docs
|
67
|
+
|
68
|
+
## Bugfixes
|
69
|
+
|
70
|
+
* (breaking) Stop handling string filters as regular expressions, use the dedicated regex filter if you need that behaviour. See [#616](https://github.com/colszowka/simplecov/pull/616) (thanks @yujinakayama)
|
71
|
+
* Avoid overwriting the last coverage results on unsuccessful test runs. See [#625](https://github.com/colszowka/simplecov/pull/625) (thanks @thomas07vt)
|
72
|
+
* Don't crash on invalid UTF-8 byte sequences. (thanks @BMorearty)
|
73
|
+
|
1
74
|
0.15.1 (2017-09-11) ([changes](https://github.com/colszowka/simplecov/compare/v0.15.0...v0.15.1))
|
2
75
|
=======
|
3
76
|
|
@@ -16,7 +89,7 @@
|
|
16
89
|
## Bugfixes
|
17
90
|
|
18
91
|
* Fix merging race condition when running tests in parallel and merging them. See [#570](https://github.com/colszowka/simplecov/pull/570) (thanks @jenseng)
|
19
|
-
* Fix relevant lines for unloaded files - comments, skipped code etc. are correctly
|
92
|
+
* Fix relevant lines for unloaded files - comments, skipped code etc. are correctly classified as irrelevant. See [#605](https://github.com/colszowka/simplecov/pull/605) (thanks @odlp)
|
20
93
|
* Allow using simplecov with frozen-string-literals enabled. See [#590](https://github.com/colszowka/simplecov/pull/590) (thanks @pat)
|
21
94
|
* Make sure Array Filter can use all other filter types. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
22
95
|
* Make sure file names use `Simplecov.root` as base avoiding using full absolute project paths. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# SimpleCov Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at simplecov.team@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/CONTRIBUTING.md
CHANGED
@@ -2,19 +2,21 @@
|
|
2
2
|
|
3
3
|
You can report issues at https://github.com/colszowka/simplecov/issues
|
4
4
|
|
5
|
-
|
5
|
+
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
6
6
|
|
7
|
+
To make sure that we can help you quickly please include and check the following information:
|
8
|
+
|
9
|
+
* Include how you run your tests and which testing framework or frameworks you are running.
|
10
|
+
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
11
|
+
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
12
|
+
For example, if running via RSpec, this would be at the top of your spec_helper.
|
13
|
+
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
7
14
|
* Include the SimpleCov version you are running in your report.
|
8
15
|
* If you are not running the latest version (please check), and you cannot update it,
|
9
16
|
please specify in your report why you can't update to the latest version.
|
10
17
|
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
11
18
|
* Please also specify the gem versions of Rails (if applicable).
|
12
19
|
* Include any other coverage gems you may be using and their versions.
|
13
|
-
* Include how you run your tests and which testing framework or frameworks you are running.
|
14
|
-
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
15
|
-
- Otherwise, please ensure you are requiring and starting SimpleCov before requiring any application code.
|
16
|
-
For example, if running via RSpec, this would be at the top of your spec_helper.
|
17
|
-
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
18
20
|
|
19
21
|
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
20
22
|
|
@@ -37,12 +39,13 @@ If you want to contribute, please:
|
|
37
39
|
* Make your feature addition or bug fix.
|
38
40
|
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
39
41
|
* **Bonus Points** go out to anyone who also updates `CHANGELOG.md` :)
|
40
|
-
* Send me a pull request on
|
42
|
+
* Send me a pull request on GitHub.
|
41
43
|
|
42
44
|
## Running Individual Tests
|
43
45
|
|
44
|
-
This project uses
|
46
|
+
This project uses RSpec and Cucumber. Individual tests can be run like this:
|
45
47
|
|
46
48
|
```bash
|
47
|
-
|
49
|
+
bundle exec rspec path/to/test.rb
|
50
|
+
bundle exec cucumber path/to/test.feature
|
48
51
|
```
|
data/ISSUE_TEMPLATE.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Howdy! Thanks for reporting an issue <3
|
2
|
+
|
3
|
+
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
4
|
+
|
5
|
+
To make sure that we can help you quickly please include and check the following information:
|
6
|
+
|
7
|
+
* Include how you run your tests and which testing framework or frameworks you are running.
|
8
|
+
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
9
|
+
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
10
|
+
For example, if running via RSpec, this would be at the top of your spec_helper.
|
11
|
+
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
12
|
+
* Include the SimpleCov version you are running in your report.
|
13
|
+
* If you are not running the latest version (please check), and you cannot update it,
|
14
|
+
please specify in your report why you can't update to the latest version.
|
15
|
+
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
16
|
+
* Please also specify the gem versions of Rails (if applicable).
|
17
|
+
* Include any other coverage gems you may be using and their versions.
|
18
|
+
|
19
|
+
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
20
|
+
|
21
|
+
This is extremely important for narrowing down the cause of your problem.
|
22
|
+
|
23
|
+
Thanks!
|
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
SimpleCov [![
|
1
|
+
SimpleCov [![Gem Version](https://badge.fury.io/rb/simplecov.svg)](https://badge.fury.io/rb/simplecov) [![Build Status](https://travis-ci.org/colszowka/simplecov.svg?branch=master)][Continuous Integration] [![Code Climate](https://codeclimate.com/github/colszowka/simplecov.svg)](https://codeclimate.com/github/colszowka/simplecov) [![Inline docs](http://inch-ci.org/github/colszowka/simplecov.svg)](http://inch-ci.org/github/colszowka/simplecov)
|
2
2
|
=========
|
3
3
|
**Code coverage for Ruby**
|
4
4
|
|
@@ -8,7 +8,7 @@ SimpleCov [![Build Status](https://travis-ci.org/colszowka/simplecov.svg)][Conti
|
|
8
8
|
* [Rubygem]
|
9
9
|
* [Continuous Integration]
|
10
10
|
|
11
|
-
[Coverage]:
|
11
|
+
[Coverage]: https://ruby-doc.org/stdlib/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
|
12
12
|
[Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
|
13
13
|
[API documentation]: http://rubydoc.info/gems/simplecov/frames "RDoc API Documentation at Rubydoc.info"
|
14
14
|
[Configuration]: http://rubydoc.info/gems/simplecov/SimpleCov/Configuration "Configuration options API documentation"
|
@@ -22,13 +22,14 @@ SimpleCov is a code coverage analysis tool for Ruby. It uses [Ruby's built-in Co
|
|
22
22
|
coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format,
|
23
23
|
and display those results, giving you a complete code coverage suite that can be set up with just a couple lines of
|
24
24
|
code.
|
25
|
+
SimpleCov/Coverage track covered ruby code, gathering coverage for common templating solutions like erb, slim and haml is not supported.
|
25
26
|
|
26
27
|
In most cases, you'll want overall coverage results for your projects, including all types of tests, Cucumber features,
|
27
28
|
etc. SimpleCov automatically takes care of this by caching and merging results when generating reports, so your
|
28
29
|
report actually includes coverage across your test suites and thereby gives you a better picture of blank spots.
|
29
30
|
|
30
|
-
The official formatter of SimpleCov is packaged as a separate gem called [simplecov-html], but will be installed and
|
31
|
-
automatically when you launch SimpleCov. If you're curious, you can find it [on
|
31
|
+
The official formatter of SimpleCov is packaged as a separate gem called [simplecov-html], but will be installed and
|
32
|
+
configured automatically when you launch SimpleCov. If you're curious, you can find it [on GitHub, too][simplecov-html].
|
32
33
|
|
33
34
|
|
34
35
|
## Contact
|
@@ -36,21 +37,23 @@ automatically when you launch SimpleCov. If you're curious, you can find it [on
|
|
36
37
|
*Code and Bug Reports*
|
37
38
|
|
38
39
|
* [Issue Tracker](https://github.com/colszowka/simplecov/issues)
|
39
|
-
* See [CONTRIBUTING](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md) for how to contribute along
|
40
|
+
* See [CONTRIBUTING](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md) for how to contribute along
|
41
|
+
with some common problems to check out before creating an issue.
|
40
42
|
|
41
43
|
*Questions, Problems, Suggestions, etc.*
|
42
44
|
|
43
|
-
* [Mailing List](https://groups.google.com/forum/#!forum/simplecov) "Open mailing list for discussion and announcements
|
45
|
+
* [Mailing List](https://groups.google.com/forum/#!forum/simplecov) "Open mailing list for discussion and announcements
|
46
|
+
on Google Groups"
|
44
47
|
|
45
48
|
Getting started
|
46
49
|
---------------
|
47
50
|
1. Add SimpleCov to your `Gemfile` and `bundle install`:
|
48
51
|
|
49
52
|
```ruby
|
50
|
-
gem 'simplecov', :
|
53
|
+
gem 'simplecov', require: false, group: :test
|
51
54
|
```
|
52
55
|
2. Load and launch SimpleCov **at the very top** of your `test/test_helper.rb`
|
53
|
-
(*or `spec_helper.rb`, cucumber `env.rb`, or whatever your preferred test
|
56
|
+
(*or `spec_helper.rb`, `rails_helper`, cucumber `env.rb`, or whatever your preferred test
|
54
57
|
framework uses*):
|
55
58
|
|
56
59
|
```ruby
|
@@ -70,8 +73,8 @@ Getting started
|
|
70
73
|
endpoint) via a separate test process (e.g. when using Selenium) where you
|
71
74
|
want to see all code executed by the `rails server`, and not just code
|
72
75
|
executed in your actual test files, you'll want to add something like this
|
73
|
-
to the top of `
|
74
|
-
|
76
|
+
to the top of `bin/rails`, but below the "shebang" line (`#! /usr/bin/env
|
77
|
+
ruby`):
|
75
78
|
|
76
79
|
```ruby
|
77
80
|
if ENV['RAILS_ENV'] == 'test'
|
@@ -81,23 +84,41 @@ Getting started
|
|
81
84
|
end
|
82
85
|
```
|
83
86
|
|
84
|
-
3. Run your
|
85
|
-
|
86
|
-
|
87
|
+
3. Run your full test suite to see the percent coverage that your application has.
|
88
|
+
4. After running your tests, open `coverage/index.html` in the browser of your choice. For example, in a Mac Terminal,
|
89
|
+
run the following command from your application's root directory:
|
90
|
+
|
91
|
+
```
|
92
|
+
open coverage/index.html
|
93
|
+
```
|
94
|
+
in a debian/ubuntu Terminal,
|
95
|
+
|
96
|
+
```
|
97
|
+
xdg-open coverage/index.html
|
98
|
+
```
|
99
|
+
|
100
|
+
**Note:** [This guide](https://dwheeler.com/essays/open-files-urls.html) can help if you're unsure which command your particular
|
101
|
+
operating system requires.
|
102
|
+
|
103
|
+
5. Add the following to your `.gitignore` file to ensure that coverage results
|
87
104
|
are not tracked by Git (optional):
|
88
105
|
|
89
|
-
|
90
|
-
|
91
|
-
|
106
|
+
```
|
107
|
+
echo "coverage" >> .gitignore
|
108
|
+
```
|
109
|
+
Or if you use Windows:
|
110
|
+
```
|
111
|
+
echo coverage >> .gitignore
|
112
|
+
```
|
92
113
|
|
93
|
-
|
94
|
-
|
95
|
-
|
114
|
+
If you're making a Rails application, SimpleCov comes with built-in configurations (see below for information on
|
115
|
+
profiles) that will get you started with groups for your Controllers, Models and Helpers. To use it, the
|
116
|
+
first two lines of your test_helper should be like this:
|
96
117
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
118
|
+
```ruby
|
119
|
+
require 'simplecov'
|
120
|
+
SimpleCov.start 'rails'
|
121
|
+
```
|
101
122
|
|
102
123
|
## Example output
|
103
124
|
|
@@ -123,8 +144,9 @@ require 'simplecov'
|
|
123
144
|
SimpleCov.start 'rails'
|
124
145
|
```
|
125
146
|
|
126
|
-
You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov
|
127
|
-
care what kind of framework it is running in; it just looks at what code is being executed and generates a
|
147
|
+
You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov
|
148
|
+
does not care what kind of framework it is running in; it just looks at what code is being executed and generates a
|
149
|
+
report about it.
|
128
150
|
|
129
151
|
### Notes on specific frameworks and test utilities
|
130
152
|
|
@@ -133,17 +155,6 @@ to use SimpleCov with them. Here's an overview of the known ones:
|
|
133
155
|
|
134
156
|
<table>
|
135
157
|
<tr><th>Framework</th><th>Notes</th><th>Issue</th></tr>
|
136
|
-
<tr>
|
137
|
-
<th>
|
138
|
-
bootsnap
|
139
|
-
</th>
|
140
|
-
<td>
|
141
|
-
<a href="#want-to-use-bootsnap-with-simplecov">See section below.</a>
|
142
|
-
</td>
|
143
|
-
<td>
|
144
|
-
<a href="https://github.com/Shopify/bootsnap/issues/35">Shopify/bootsnap#35</a>
|
145
|
-
</td>
|
146
|
-
</tr>
|
147
158
|
<tr>
|
148
159
|
<th>
|
149
160
|
parallel_tests
|
@@ -230,7 +241,8 @@ to use SimpleCov with them. Here's an overview of the known ones:
|
|
230
241
|
```ruby
|
231
242
|
SimpleCov.some_config_option 'foo'
|
232
243
|
```
|
233
|
-
* If you do not want to start coverage immediately after launch or want to add additional configuration later on in a
|
244
|
+
* If you do not want to start coverage immediately after launch or want to add additional configuration later on in a
|
245
|
+
concise way, use:
|
234
246
|
|
235
247
|
```ruby
|
236
248
|
SimpleCov.configure do
|
@@ -242,11 +254,12 @@ Please check out the [Configuration] API documentation to find out what you can
|
|
242
254
|
|
243
255
|
## Using .simplecov for centralized config
|
244
256
|
|
245
|
-
If you use SimpleCov to merge multiple test suite results (e.g. Test/Unit and Cucumber) into a single report, you'd
|
246
|
-
set up all your config options twice, once in `test_helper.rb` and once in `env.rb`.
|
257
|
+
If you use SimpleCov to merge multiple test suite results (e.g. Test/Unit and Cucumber) into a single report, you'd
|
258
|
+
normally have to set up all your config options twice, once in `test_helper.rb` and once in `env.rb`.
|
247
259
|
|
248
|
-
To avoid this, you can place a file called `.simplecov` in your project root. You can then just leave the
|
249
|
-
test setup helper and move the `SimpleCov.start` code with all your
|
260
|
+
To avoid this, you can place a file called `.simplecov` in your project root. You can then just leave the
|
261
|
+
`require 'simplecov'` in each test setup helper (**at the top**) and move the `SimpleCov.start` code with all your
|
262
|
+
custom config options into `.simplecov`:
|
250
263
|
|
251
264
|
```ruby
|
252
265
|
# test/test_helper.rb
|
@@ -260,21 +273,70 @@ SimpleCov.start 'rails' do
|
|
260
273
|
# any custom configs like groups and filters can be here at a central place
|
261
274
|
end
|
262
275
|
```
|
263
|
-
|
276
|
+
|
277
|
+
Using `.simplecov` rather than separately requiring SimpleCov multiple times is recommended if you are merging multiple
|
278
|
+
test frameworks like Cucumber and RSpec that rely on each other, as invoking SimpleCov multiple times can cause coverage
|
279
|
+
information to be lost.
|
280
|
+
|
281
|
+
## Branch coverage (ruby "~> 2.5")
|
282
|
+
Add branch coverage measurement statistics to your results. Supported in CRuby versions 2.5+.
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
# or in configure or just SimpleCov.enable_coverage :branch
|
286
|
+
SimpleCov.start do
|
287
|
+
enable_coverage :branch
|
288
|
+
end
|
289
|
+
```
|
290
|
+
|
291
|
+
Branch coverage is a feature introduced in Ruby 2.5 concerning itself with whether a
|
292
|
+
particular branch of a condition had been executed. Line coverage on the other hand
|
293
|
+
is only interested in whether a line of code has been executed.
|
294
|
+
|
295
|
+
This comes in handy for instance for one line conditionals:
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
number.odd? ? "odd" : "even"
|
299
|
+
```
|
300
|
+
|
301
|
+
In line coverage this line would always be marked as executed but you'd never know if both
|
302
|
+
conditions were met. Guard clauses have a similar story:
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
return if number.odd?
|
306
|
+
|
307
|
+
# more code
|
308
|
+
```
|
309
|
+
|
310
|
+
If all the code in that method was covered you'd never know if the guard clause was ever
|
311
|
+
triggered with line coverage as just evaluating the condition marks it as covered.
|
312
|
+
|
313
|
+
In the HTML report the lines of code will be annotated like `hit_count, positive_or_negative_branch`:
|
314
|
+
|
315
|
+
* `2, +` - the positive branch was executed twice
|
316
|
+
* `0, -` - the negative branch was never executed
|
317
|
+
|
318
|
+
**Is branch coverage strictly better?** No. Branch coverage really only concerns itself with
|
319
|
+
conditionals - meaning coverage of sequential code is of no interest to it. A file without
|
320
|
+
conditional logic will have no branch coverage data and SimpleCov will report 0 of 0
|
321
|
+
branches covered as 100% (as everything that can be covered was covered).
|
322
|
+
|
323
|
+
Hence, we recommend looking at both metrics together. Branch coverage might also be a good
|
324
|
+
overall metric to look at - while you might be missing only 10% of your lines that might
|
325
|
+
account for 50% of your branches for instance.
|
264
326
|
|
265
327
|
## Filters
|
266
328
|
|
267
|
-
Filters can be used to remove selected files from your coverage data. By default, a filter is applied that removes all
|
268
|
-
OUTSIDE of your project's root directory - otherwise you'd end up with billions of coverage reports for source
|
269
|
-
gems you are using.
|
329
|
+
Filters can be used to remove selected files from your coverage data. By default, a filter is applied that removes all
|
330
|
+
files OUTSIDE of your project's root directory - otherwise you'd end up with billions of coverage reports for source
|
331
|
+
files in the gems you are using.
|
270
332
|
|
271
333
|
You can define your own to remove things like configuration files, tests or whatever you don't need in your coverage
|
272
334
|
report.
|
273
335
|
|
274
336
|
### Defining custom filters
|
275
337
|
|
276
|
-
You can currently define a filter using either a String or Regexp (that will then be Regexp-matched against each source
|
277
|
-
a block or by passing in your own Filter class.
|
338
|
+
You can currently define a filter using either a String or Regexp (that will then be Regexp-matched against each source
|
339
|
+
file's path), a block or by passing in your own Filter class.
|
278
340
|
|
279
341
|
#### String filter
|
280
342
|
|
@@ -306,9 +368,10 @@ SimpleCov.start do
|
|
306
368
|
end
|
307
369
|
```
|
308
370
|
|
309
|
-
Block filters receive a SimpleCov::SourceFile instance and expect your block to return either true (if the file is to be
|
310
|
-
from the result) or false (if the result should be kept). Please check out the RDoc for SimpleCov::SourceFile to
|
311
|
-
methods available to you. In the above example, the filter will remove all files that have less than 5
|
371
|
+
Block filters receive a SimpleCov::SourceFile instance and expect your block to return either true (if the file is to be
|
372
|
+
removed from the result) or false (if the result should be kept). Please check out the RDoc for SimpleCov::SourceFile to
|
373
|
+
learn about the methods available to you. In the above example, the filter will remove all files that have less than 5
|
374
|
+
lines of code.
|
312
375
|
|
313
376
|
#### Custom filter class
|
314
377
|
|
@@ -322,9 +385,10 @@ end
|
|
322
385
|
SimpleCov.add_filter LineFilter.new(5)
|
323
386
|
```
|
324
387
|
|
325
|
-
Defining your own filters is pretty easy: Just inherit from SimpleCov::Filter and define a method
|
326
|
-
the filter, a true return value from this method will result in the removal of the
|
327
|
-
is being set in the SimpleCov::Filter initialize method and thus is set to
|
388
|
+
Defining your own filters is pretty easy: Just inherit from SimpleCov::Filter and define a method
|
389
|
+
'matches?(source_file)'. When running the filter, a true return value from this method will result in the removal of the
|
390
|
+
given source_file. The filter_argument method is being set in the SimpleCov::Filter initialize method and thus is set to
|
391
|
+
5 in this example.
|
328
392
|
|
329
393
|
#### Array filter
|
330
394
|
|
@@ -351,7 +415,9 @@ end
|
|
351
415
|
|
352
416
|
The name of the token can be changed to your liking. [Learn more about the nocov feature.]( https://github.com/colszowka/simplecov/blob/master/features/config_nocov_token.feature)
|
353
417
|
|
354
|
-
**Note:** You shouldn't have to use the nocov token to skip private methods that are being included in your coverage. If
|
418
|
+
**Note:** You shouldn't have to use the nocov token to skip private methods that are being included in your coverage. If
|
419
|
+
you appropriately test the public interface of your classes and objects you should automatically get full coverage of
|
420
|
+
your private methods.
|
355
421
|
|
356
422
|
## Default root filter and coverage for things outside of it
|
357
423
|
|
@@ -374,8 +440,8 @@ end
|
|
374
440
|
|
375
441
|
You can separate your source files into groups. For example, in a Rails app, you'll want to have separate listings for
|
376
442
|
Models, Controllers, Helpers, and Libs. Group definition works similarly to Filters (and also accepts custom
|
377
|
-
filter classes), but source files end up in a group when the filter passes (returns true), as opposed to filtering
|
378
|
-
which exclude files from results when the filter results in a true value.
|
443
|
+
filter classes), but source files end up in a group when the filter passes (returns true), as opposed to filtering
|
444
|
+
results, which exclude files from results when the filter results in a true value.
|
379
445
|
|
380
446
|
Add your groups with:
|
381
447
|
|
@@ -465,13 +531,15 @@ You can deactivate merging altogether with `SimpleCov.use_merging false`.
|
|
465
531
|
|
466
532
|
## Running coverage only on demand
|
467
533
|
|
468
|
-
The Ruby STDLIB Coverage library that SimpleCov builds upon is *very* fast (on a ~10 min Rails test suite, the speed
|
469
|
-
only a couple seconds for me), and therefore it's SimpleCov's policy to just generate coverage every time you
|
470
|
-
it doesn't do your test speed any harm and you're always equipped with the latest and greatest
|
534
|
+
The Ruby STDLIB Coverage library that SimpleCov builds upon is *very* fast (on a ~10 min Rails test suite, the speed
|
535
|
+
drop was only a couple seconds for me), and therefore it's SimpleCov's policy to just generate coverage every time you
|
536
|
+
run your tests because it doesn't do your test speed any harm and you're always equipped with the latest and greatest
|
537
|
+
coverage results.
|
471
538
|
|
472
539
|
Because of this, SimpleCov has no explicit built-in mechanism to run coverage only on demand.
|
473
540
|
|
474
|
-
However, you can still accomplish this very easily by introducing an ENV variable conditional into your SimpleCov setup
|
541
|
+
However, you can still accomplish this very easily by introducing an ENV variable conditional into your SimpleCov setup
|
542
|
+
block, like this:
|
475
543
|
|
476
544
|
```ruby
|
477
545
|
SimpleCov.start if ENV["COVERAGE"]
|
@@ -483,6 +551,21 @@ Then, SimpleCov will only run if you execute your tests like this:
|
|
483
551
|
COVERAGE=true rake test
|
484
552
|
```
|
485
553
|
|
554
|
+
## Errors and exit statuses
|
555
|
+
|
556
|
+
To aid in debugging issues, if an error is raised, SimpleCov will print a message to `STDERR`
|
557
|
+
with the exit status of the error, like:
|
558
|
+
|
559
|
+
```
|
560
|
+
SimpleCov failed with exit 1
|
561
|
+
```
|
562
|
+
|
563
|
+
This `STDERR` message can be disabled with:
|
564
|
+
|
565
|
+
```
|
566
|
+
SimpleCov.print_error_status = false
|
567
|
+
```
|
568
|
+
|
486
569
|
## Profiles
|
487
570
|
|
488
571
|
By default, SimpleCov's only config assumption is that you only want coverage reports for files inside your project
|
@@ -520,8 +603,8 @@ end
|
|
520
603
|
|
521
604
|
### Custom profiles
|
522
605
|
|
523
|
-
You can load additional profiles with the SimpleCov.load_profile('xyz') method. This allows you to build upon an
|
524
|
-
profile and customize it so you can reuse it in unit tests and Cucumber features. For example:
|
606
|
+
You can load additional profiles with the SimpleCov.load_profile('xyz') method. This allows you to build upon an
|
607
|
+
existing profile and customize it so you can reuse it in unit tests and Cucumber features. For example:
|
525
608
|
|
526
609
|
```ruby
|
527
610
|
# lib/simplecov_custom_profile.rb
|
@@ -562,7 +645,8 @@ SimpleCov.minimum_coverage 90
|
|
562
645
|
|
563
646
|
### Minimum coverage by file
|
564
647
|
|
565
|
-
You can define the minimum coverage by file percentage expected. SimpleCov will return non-zero if unmet. This is useful
|
648
|
+
You can define the minimum coverage by file percentage expected. SimpleCov will return non-zero if unmet. This is useful
|
649
|
+
to help ensure coverage is relatively consistent, rather than being skewed by particularly good or bad areas of the code.
|
566
650
|
|
567
651
|
```ruby
|
568
652
|
SimpleCov.minimum_coverage_by_file 80
|
@@ -592,8 +676,8 @@ You can use your own formatter with:
|
|
592
676
|
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
593
677
|
```
|
594
678
|
|
595
|
-
When calling SimpleCov.result.format!, it will be invoked with SimpleCov::Formatter::YourFormatter.new.format(result),
|
596
|
-
being an instance of SimpleCov::Result. Do whatever your wish with that!
|
679
|
+
When calling SimpleCov.result.format!, it will be invoked with SimpleCov::Formatter::YourFormatter.new.format(result),
|
680
|
+
"result" being an instance of SimpleCov::Result. Do whatever your wish with that!
|
597
681
|
|
598
682
|
|
599
683
|
## Using multiple formatters
|
@@ -615,11 +699,9 @@ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
|
|
615
699
|
|
616
700
|
## Ruby version compatibility
|
617
701
|
|
618
|
-
|
619
|
-
SimpleCov is also built against Ruby 1.8 in [Continuous Integration], but this happens only to ensure that SimpleCov
|
620
|
-
does not make your test suite crash right now.
|
702
|
+
SimpleCov is built in [Continuous Integration] on Ruby 2.4+ as well as JRuby 9.2+.
|
621
703
|
|
622
|
-
|
704
|
+
Note for JRuby => You need to pass JRUBY_OPTS="--debug" or create .jrubyrc and add debug.fullTrace=true
|
623
705
|
|
624
706
|
## Want to find dead code in production?
|
625
707
|
|
@@ -627,48 +709,67 @@ Try [Coverband](https://github.com/danmayer/coverband).
|
|
627
709
|
|
628
710
|
## Want to use Spring with SimpleCov?
|
629
711
|
|
630
|
-
If you're using [Spring](https://github.com/rails/spring) to speed up test suite runs and want to run SimpleCov along
|
712
|
+
If you're using [Spring](https://github.com/rails/spring) to speed up test suite runs and want to run SimpleCov along
|
713
|
+
with them, you'll find that it often misreports coverage with the default config due to some sort of eager loading
|
714
|
+
issue. Don't despair!
|
631
715
|
|
632
|
-
|
716
|
+
One solution is to [explicitly call eager
|
717
|
+
load](https://github.com/colszowka/simplecov/issues/381#issuecomment-347651728)
|
718
|
+
in your `test_helper.rb` / `spec_helper.rb` after calling `SimpleCov.start`.
|
633
719
|
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
# For Rails 5, use the following configuration:
|
641
|
-
# Disable Rails's static asset server (Apache or nginx will already do this)
|
642
|
-
config.public_file_server.enabled = false
|
643
|
-
config.eager_load = false
|
644
|
-
```
|
645
|
-
2. Add your SimpleCov config, as you normally would, to your `spec_helper.rb`
|
646
|
-
(or `rails_helper.rb` for RSpec 3). If you have a `config/spring.rb` file
|
647
|
-
(or anything similar), add it to the start of such file. Here's a simple
|
648
|
-
version of what the config should look like:
|
720
|
+
```ruby
|
721
|
+
require 'simplecov'
|
722
|
+
SimpleCov.start 'rails'
|
723
|
+
Rails.application.eager_load!
|
724
|
+
```
|
649
725
|
|
650
|
-
|
651
|
-
if ENV['RAILS_ENV'] == 'test'
|
652
|
-
require 'simplecov'
|
653
|
-
SimpleCov.start
|
654
|
-
end
|
655
|
-
```
|
656
|
-
3. Run `spring rspec <path>` as normal. Remember to run `spring stop` after
|
657
|
-
making important changes to your app or its specs!
|
658
|
-
|
659
|
-
## Want to use bootsnap with SimpleCov?
|
726
|
+
Alternatively, you could disable Spring while running SimpleCov:
|
660
727
|
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
728
|
+
```
|
729
|
+
DISABLE_SPRING=1 rake test
|
730
|
+
```
|
731
|
+
|
732
|
+
Or you could remove `gem 'spring'` from your `Gemfile`.
|
733
|
+
|
734
|
+
## Troubleshooting
|
735
|
+
|
736
|
+
The **most common problem is that simplecov isn't required and started before everything else**. In order to track
|
737
|
+
coverage for your whole application **simplecov needs to be the first one** so that it (and the underlying coverage
|
738
|
+
library) can subsequently track loaded files and their usage.
|
739
|
+
|
740
|
+
If you are missing coverage for some code a simple trick is to put a puts statement in there and right after
|
741
|
+
`SimpleCov.start` so you can see if the file really was loaded after simplecov was started.
|
665
742
|
|
666
743
|
```ruby
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
744
|
+
# my_code.rb
|
745
|
+
class MyCode
|
746
|
+
|
747
|
+
puts "MyCode is being loaded!"
|
748
|
+
|
749
|
+
def my_method
|
750
|
+
# ...
|
751
|
+
end
|
752
|
+
end
|
753
|
+
|
754
|
+
# spec_helper.rb/rails_helper.rb/test_helper.rb/.simplecov whatever
|
755
|
+
|
756
|
+
SimpleCov.start
|
757
|
+
puts "SimpleCov started successfully!"
|
758
|
+
```
|
759
|
+
|
760
|
+
Now when you run your test suite and you see:
|
761
|
+
|
671
762
|
```
|
763
|
+
SimpleCov started successfully!
|
764
|
+
MyCode is being loaded!
|
765
|
+
```
|
766
|
+
|
767
|
+
then it's good otherwise you likely have a problem :)
|
768
|
+
|
769
|
+
## Code of Conduct
|
770
|
+
|
771
|
+
Everyone participating in this project's development, issue trackers and other channels is expected to follow our
|
772
|
+
[Code of Conduct](./CODE_OF_CONDUCT.md)
|
672
773
|
|
673
774
|
## Contributing
|
674
775
|
|