simplecov 0.15.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +116 -1
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +12 -9
  5. data/ISSUE_TEMPLATE.md +23 -0
  6. data/{MIT-LICENSE → LICENSE} +0 -0
  7. data/README.md +302 -116
  8. data/doc/alternate-formatters.md +20 -0
  9. data/lib/simplecov.rb +321 -45
  10. data/lib/simplecov/combine.rb +30 -0
  11. data/lib/simplecov/combine/branches_combiner.rb +32 -0
  12. data/lib/simplecov/combine/files_combiner.rb +24 -0
  13. data/lib/simplecov/combine/lines_combiner.rb +43 -0
  14. data/lib/simplecov/combine/results_combiner.rb +60 -0
  15. data/lib/simplecov/command_guesser.rb +8 -3
  16. data/lib/simplecov/configuration.rb +112 -9
  17. data/lib/simplecov/coverage_statistics.rb +56 -0
  18. data/lib/simplecov/defaults.rb +13 -80
  19. data/lib/simplecov/exit_codes.rb +2 -0
  20. data/lib/simplecov/file_list.rb +68 -13
  21. data/lib/simplecov/filter.rb +5 -2
  22. data/lib/simplecov/formatter.rb +2 -0
  23. data/lib/simplecov/formatter/multi_formatter.rb +4 -2
  24. data/lib/simplecov/formatter/simple_formatter.rb +6 -4
  25. data/lib/simplecov/last_run.rb +5 -1
  26. data/lib/simplecov/lines_classifier.rb +21 -5
  27. data/lib/simplecov/load_global_config.rb +2 -0
  28. data/lib/simplecov/no_defaults.rb +2 -0
  29. data/lib/simplecov/profiles.rb +11 -7
  30. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  31. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  32. data/lib/simplecov/profiles/rails.rb +18 -0
  33. data/lib/simplecov/profiles/root_filter.rb +10 -0
  34. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  35. data/lib/simplecov/result.rb +41 -6
  36. data/lib/simplecov/result_adapter.rb +30 -0
  37. data/lib/simplecov/result_merger.rb +20 -11
  38. data/lib/simplecov/simulate_coverage.rb +29 -0
  39. data/lib/simplecov/source_file.rb +225 -126
  40. data/lib/simplecov/source_file/branch.rb +84 -0
  41. data/lib/simplecov/source_file/line.rb +72 -0
  42. data/lib/simplecov/useless_results_remover.rb +16 -0
  43. data/lib/simplecov/version.rb +3 -1
  44. metadata +43 -160
  45. data/.gitignore +0 -31
  46. data/.rspec +0 -3
  47. data/.rubocop.yml +0 -88
  48. data/.travis.yml +0 -29
  49. data/.yardopts +0 -1
  50. data/Gemfile +0 -38
  51. data/Rakefile +0 -39
  52. data/cucumber.yml +0 -13
  53. data/features/config_autoload.feature +0 -46
  54. data/features/config_command_name.feature +0 -45
  55. data/features/config_coverage_dir.feature +0 -33
  56. data/features/config_deactivate_merging.feature +0 -42
  57. data/features/config_formatters.feature +0 -77
  58. data/features/config_merge_timeout.feature +0 -39
  59. data/features/config_nocov_token.feature +0 -79
  60. data/features/config_profiles.feature +0 -44
  61. data/features/config_project_name.feature +0 -27
  62. data/features/config_styles.feature +0 -121
  63. data/features/config_tracked_files.feature +0 -29
  64. data/features/config_tracked_files_relevant_lines.feature +0 -31
  65. data/features/cucumber_basic.feature +0 -29
  66. data/features/maximum_coverage_drop.feature +0 -89
  67. data/features/merging_test_unit_and_rspec.feature +0 -44
  68. data/features/minimum_coverage.feature +0 -59
  69. data/features/refuse_coverage_drop.feature +0 -95
  70. data/features/rspec_basic.feature +0 -32
  71. data/features/rspec_fails_on_initialization.feature +0 -14
  72. data/features/rspec_groups_and_filters_basic.feature +0 -29
  73. data/features/rspec_groups_and_filters_complex.feature +0 -37
  74. data/features/rspec_groups_using_filter_class.feature +0 -41
  75. data/features/rspec_without_simplecov.feature +0 -20
  76. data/features/skipping_code_blocks_manually.feature +0 -70
  77. data/features/step_definitions/html_steps.rb +0 -44
  78. data/features/step_definitions/simplecov_steps.rb +0 -68
  79. data/features/step_definitions/transformers.rb +0 -13
  80. data/features/step_definitions/web_steps.rb +0 -64
  81. data/features/support/aruba_freedom_patch.rb +0 -53
  82. data/features/support/env.rb +0 -50
  83. data/features/test_unit_basic.feature +0 -34
  84. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  85. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  86. data/features/test_unit_groups_using_filter_class.feature +0 -40
  87. data/features/test_unit_without_simplecov.feature +0 -20
  88. data/features/unicode_compatiblity.feature +0 -67
  89. data/lib/simplecov/jruby_fix.rb +0 -42
  90. data/lib/simplecov/railtie.rb +0 -7
  91. data/lib/simplecov/railties/tasks.rake +0 -11
  92. data/lib/simplecov/raw_coverage.rb +0 -39
  93. data/simplecov.gemspec +0 -27
  94. data/spec/1_8_fallbacks_spec.rb +0 -31
  95. data/spec/command_guesser_spec.rb +0 -48
  96. data/spec/config_loader_spec.rb +0 -14
  97. data/spec/configuration_spec.rb +0 -35
  98. data/spec/defaults_spec.rb +0 -41
  99. data/spec/deleted_source_spec.rb +0 -12
  100. data/spec/faked_project/Gemfile +0 -6
  101. data/spec/faked_project/Rakefile +0 -8
  102. data/spec/faked_project/cucumber.yml +0 -13
  103. data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
  104. data/spec/faked_project/features/support/env.rb +0 -12
  105. data/spec/faked_project/features/test_stuff.feature +0 -6
  106. data/spec/faked_project/lib/faked_project.rb +0 -11
  107. data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
  108. data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
  109. data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
  110. data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
  111. data/spec/faked_project/spec/faked_spec.rb +0 -11
  112. data/spec/faked_project/spec/forking_spec.rb +0 -8
  113. data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
  114. data/spec/faked_project/spec/some_class_spec.rb +0 -13
  115. data/spec/faked_project/spec/spec_helper.rb +0 -11
  116. data/spec/faked_project/test/faked_test.rb +0 -11
  117. data/spec/faked_project/test/meta_magic_test.rb +0 -13
  118. data/spec/faked_project/test/some_class_test.rb +0 -15
  119. data/spec/faked_project/test/test_helper.rb +0 -12
  120. data/spec/file_list_spec.rb +0 -50
  121. data/spec/filters_spec.rb +0 -202
  122. data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
  123. data/spec/fixtures/app/models/user.rb +0 -10
  124. data/spec/fixtures/deleted_source_sample.rb +0 -15
  125. data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
  126. data/spec/fixtures/frameworks/rspec_good.rb +0 -9
  127. data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
  128. data/spec/fixtures/frameworks/testunit_good.rb +0 -9
  129. data/spec/fixtures/iso-8859.rb +0 -3
  130. data/spec/fixtures/never.rb +0 -2
  131. data/spec/fixtures/resultset1.rb +0 -4
  132. data/spec/fixtures/resultset2.rb +0 -4
  133. data/spec/fixtures/sample.rb +0 -16
  134. data/spec/fixtures/skipped.rb +0 -4
  135. data/spec/fixtures/skipped_and_executed.rb +0 -8
  136. data/spec/fixtures/utf-8.rb +0 -3
  137. data/spec/helper.rb +0 -26
  138. data/spec/last_run_spec.rb +0 -48
  139. data/spec/lines_classifier_spec.rb +0 -103
  140. data/spec/multi_formatter_spec.rb +0 -20
  141. data/spec/raw_coverage_spec.rb +0 -92
  142. data/spec/result_merger_spec.rb +0 -171
  143. data/spec/result_spec.rb +0 -209
  144. data/spec/return_codes_spec.rb +0 -34
  145. data/spec/simplecov_spec.rb +0 -109
  146. data/spec/source_file_line_spec.rb +0 -155
  147. data/spec/source_file_spec.rb +0 -145
  148. 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: f8f001c1d4f9343c21eee5371b68f31a56caf35b752a08a662115418176a6156
4
- data.tar.gz: 519eaaee340436685bc0c31a61d9fc1356072e1d39d573bce8049afe79332252
3
+ metadata.gz: ce12d99507e5e8bd75399d80855c495907b8dda937fb5e2a33d2895e9f74e370
4
+ data.tar.gz: ae53aefe53c30c3b1d6c1c0b70aa34c1193642d4a879f77a0c3522960fc92773
5
5
  SHA512:
6
- metadata.gz: 94a6c0d8f0245befdf662d339bae1b2e0d4a077d3591764f9c215f06453f9e86a40127d3fe5f7488875c470caf8743d19307352e72eaff6f5dfc2c657a828622
7
- data.tar.gz: eb674773b777504acba00508c7cc62f2e0f1451fb26d1a06463a822130e2cceeda4a8aba964569579becd62b7951f5968dbdd351549143cc81a69e1628923cad
6
+ metadata.gz: e9a60e36936b9b5018a6998ade1742373bfa67b96688411ab42c90ac82ca6280abe9d407dcef4d45398ed28803ca876d6f82ce0cabc878d6141897cca4dab91e
7
+ data.tar.gz: 7056045c2385516ce0029af14558bd95c9c84bc85319d82bddfcf2011b7db87a5291168bb739c1ff02d8830e133065b3f2fda605e03b7c2e6ed094b61bff9240
@@ -1,3 +1,118 @@
1
+ 0.18.0 (2020-01-28)
2
+ ===================
3
+
4
+ Huge release! Highlights are support for branch coverage (Ruby 2.5+) and dropping support for EOL'ed Ruby versions (< 2.4).
5
+ Please also read the other beta patch notes.
6
+
7
+ ## Enhancements
8
+ * You can now define the minimum expected coverage by criterion like `minimum_coverage line: 90, branch: 80`
9
+ * Memoized some internal data structures that didn't change to reduce SimpleCov overhead
10
+ * Both `FileList` and `SourceFile` now have a `coverage` method that returns a hash that points from a coverage criterion to a `CoverageStatistics` object for uniform access to overall coverage statistics for both line and branch coverage
11
+
12
+ ## Bugfixes
13
+ * we were losing precision by rounding the covered strength early, that has been removed. **For Formatters** this also means that you may need to round it yourself now.
14
+ * Removed an inconsistency in how we treat skipped vs. irrelevant lines (see [#565](https://github.com/colszowka/simplecov/issues/565)) - SimpleCov's definition of 100% is now "You covered everything that you could" so if coverage is 0/0 that's counted as a 100% no matter if the lines were irrelevant or ignored/skipped
15
+
16
+ ## Noteworthy
17
+ * `FileList` stopped inheriting from Array, it includes Enumerable so if you didn't use Array specific methods on it in formatters you should be fine
18
+
19
+ 0.18.0.beta3 (2020-01-20)
20
+ ========================
21
+
22
+ ## Enhancements
23
+ * Instead of ignoring old `.resultset.json`s that are inside the merge timeout, adapt and respect them
24
+
25
+ ## Bugfixes
26
+ * Remove the constant warning printing if you still have a `.resultset.json` in pre 0.18 layout that is within your merge timeout
27
+
28
+ 0.18.0.beta2 (2020-01-19)
29
+ ===================
30
+
31
+ ## Enhancements
32
+ * only turn on the requested coverage criteria (when activating branch coverage before SimpleCov would also instruct Ruby to take Method coverage)
33
+ * Change how branch coverage is displayed, now it's `branch_type: hit_count` which should be more self explanatory. See [#830](https://github.com/colszowka/simplecov/pull/830) for an example and feel free to give feedback!
34
+ * Allow early running exit tasks and avoid the `at_exit` hook through the `SimpleCov.run_exit_tasks!` method. (thanks [@macumber](https://github.com/macumber))
35
+ * Allow manual collation of result sets through the `SimpleCov.collate` entrypoint. See the README for more details (thanks [@ticky](https://github.com/ticky))
36
+ * Within `case`, even if there is no `else` branch declared show missing coverage for it (aka no branch of it). See [#825](https://github.com/colszowka/simplecov/pull/825)
37
+ * Stop symbolizing all keys when loading cache (should lead to be faster and consume less memory)
38
+ * Cache whether we can use/are using branch coverage (should be slightly faster)
39
+
40
+ ## Bugfixes
41
+ * Fix a crash that happened when an old version of our internal cache file `.resultset.json` was still present
42
+
43
+ 0.18.0.beta1 (2020-01-05)
44
+ ===================
45
+
46
+ 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!
47
+
48
+ 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.
49
+
50
+ 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.
51
+
52
+ ## Breaking
53
+ * Dropped support for all EOL'ed rubies meaning we only support 2.4+. Simplecov can no longer be installed on older rubies, but older simplecov releases should still work. (thanks [@deivid-rodriguez](https://github.com/deivid-rodriguez))
54
+ * 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 :)
55
+
56
+ ## Enhancements
57
+
58
+ * 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 ;)
59
+ * 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))
60
+ * 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))
61
+ * 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)
62
+
63
+ ## Bugfixes
64
+
65
+ * 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))
66
+
67
+ 0.17.1 (2019-09-16)
68
+ ===================
69
+
70
+ Bugfix release for problems with ParallelTests.
71
+
72
+ ## Bugfixes
73
+
74
+ * Avoid hanging with parallel_tests. See [#746](https://github.com/colszowka/simplecov/pull/746) (thanks [@annaswims](https://github.com/annaswims))
75
+
76
+ 0.17.0 (2019-07-02)
77
+ ===================
78
+
79
+ Maintenance release with nice convenience features and important bugfixes.
80
+ 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.
81
+
82
+ ## Enhancements
83
+
84
+ * Per default filter hidden files and folders. See [#721](https://github.com/colszowka/simplecov/pull/721) (thanks [Renuo AG](https://www.renuo.ch))
85
+ * 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))
86
+
87
+ ## Bugfixes
88
+
89
+ * 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))
90
+ * 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))
91
+ * 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))
92
+
93
+ 0.16.1 (2018-03-16)
94
+ ===================
95
+
96
+ ## Bugfixes
97
+
98
+ * Include the LICENSE in the distributed gem again (accidentally removed in 0.16.0). (thanks @tas50)
99
+
100
+ 0.16.0 (2018-03-15)
101
+ ===================
102
+
103
+ ## Enhancements
104
+
105
+ * Relax version constraint on `docile`, per SemVer
106
+ * exception that occurred on exit is available as `exit_exception`! See [#639](https://github.com/colszowka/simplecov/pull/639) (thanks @thomas07vt)
107
+ * Performance: processing results now runs from 2.5x to 3.75x faster. See [#662](https://github.com/colszowka/simplecov/pull/662) (thanks @BMorearty & @eregon)
108
+ * Decrease gem size by only shipping lib and docs
109
+
110
+ ## Bugfixes
111
+
112
+ * (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)
113
+ * Avoid overwriting the last coverage results on unsuccessful test runs. See [#625](https://github.com/colszowka/simplecov/pull/625) (thanks @thomas07vt)
114
+ * Don't crash on invalid UTF-8 byte sequences. (thanks @BMorearty)
115
+
1
116
  0.15.1 (2017-09-11) ([changes](https://github.com/colszowka/simplecov/compare/v0.15.0...v0.15.1))
2
117
  =======
3
118
 
@@ -16,7 +131,7 @@
16
131
  ## Bugfixes
17
132
 
18
133
  * 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 classigied as irrelevant. See [#605](https://github.com/colszowka/simplecov/pull/605) (thanks @odlp)
134
+ * 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
135
  * Allow using simplecov with frozen-string-literals enabled. See [#590](https://github.com/colszowka/simplecov/pull/590) (thanks @pat)
21
136
  * Make sure Array Filter can use all other filter types. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
22
137
  * 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)
@@ -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
@@ -2,19 +2,21 @@
2
2
 
3
3
  You can report issues at https://github.com/colszowka/simplecov/issues
4
4
 
5
- Search existing issues for your problem, chances are someone else already reported it.
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 Github.
42
+ * Send me a pull request on GitHub.
41
43
 
42
44
  ## Running Individual Tests
43
45
 
44
- This project uses Test::Unit. Individual tests can be run like this:
46
+ This project uses RSpec and Cucumber. Individual tests can be run like this:
45
47
 
46
48
  ```bash
47
- ruby -I test path/to/test.rb
49
+ bundle exec rspec path/to/test.rb
50
+ bundle exec cucumber path/to/test.feature
48
51
  ```
@@ -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!
File without changes
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- SimpleCov [![Build Status](https://travis-ci.org/colszowka/simplecov.svg)][Continuous Integration] [![Dependency Status](https://gemnasium.com/colszowka/simplecov.svg)][Dependencies] [![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)
1
+ SimpleCov [![Gem Version](https://badge.fury.io/rb/simplecov.svg)](https://badge.fury.io/rb/simplecov) [![Build Status](https://github.com/colszowka/simplecov/workflows/stable/badge.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
4
  **Code coverage for Ruby**
4
5
 
5
6
  * [Source Code]
@@ -8,13 +9,13 @@ SimpleCov [![Build Status](https://travis-ci.org/colszowka/simplecov.svg)][Conti
8
9
  * [Rubygem]
9
10
  * [Continuous Integration]
10
11
 
11
- [Coverage]: http://www.ruby-doc.org/stdlib-2.1.0/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
12
+ [Coverage]: https://ruby-doc.org/stdlib/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
12
13
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
13
14
  [API documentation]: http://rubydoc.info/gems/simplecov/frames "RDoc API Documentation at Rubydoc.info"
14
15
  [Configuration]: http://rubydoc.info/gems/simplecov/SimpleCov/Configuration "Configuration options API documentation"
15
16
  [Changelog]: https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md "Project Changelog"
16
17
  [Rubygem]: http://rubygems.org/gems/simplecov "SimpleCov @ rubygems.org"
17
- [Continuous Integration]: http://travis-ci.org/colszowka/simplecov "SimpleCov is built around the clock by travis-ci.org"
18
+ [Continuous Integration]: https://github.com/colszowka/simplecov/actions?query=workflow%3Astable "SimpleCov is built around the clock by github.com"
18
19
  [Dependencies]: https://gemnasium.com/colszowka/simplecov "SimpleCov dependencies on Gemnasium"
19
20
  [simplecov-html]: https://github.com/colszowka/simplecov-html "SimpleCov HTML Formatter Source Code @ GitHub"
20
21
 
@@ -22,13 +23,14 @@ SimpleCov is a code coverage analysis tool for Ruby. It uses [Ruby's built-in Co
22
23
  coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format,
23
24
  and display those results, giving you a complete code coverage suite that can be set up with just a couple lines of
24
25
  code.
26
+ SimpleCov/Coverage track covered ruby code, gathering coverage for common templating solutions like erb, slim and haml is not supported.
25
27
 
26
28
  In most cases, you'll want overall coverage results for your projects, including all types of tests, Cucumber features,
27
29
  etc. SimpleCov automatically takes care of this by caching and merging results when generating reports, so your
28
30
  report actually includes coverage across your test suites and thereby gives you a better picture of blank spots.
29
31
 
30
- The official formatter of SimpleCov is packaged as a separate gem called [simplecov-html], but will be installed and configured
31
- automatically when you launch SimpleCov. If you're curious, you can find it [on Github, too][simplecov-html].
32
+ The official formatter of SimpleCov is packaged as a separate gem called [simplecov-html], but will be installed and
33
+ configured automatically when you launch SimpleCov. If you're curious, you can find it [on GitHub, too][simplecov-html].
32
34
 
33
35
 
34
36
  ## Contact
@@ -36,21 +38,23 @@ automatically when you launch SimpleCov. If you're curious, you can find it [on
36
38
  *Code and Bug Reports*
37
39
 
38
40
  * [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 with some common problems to check out before creating an issue.
41
+ * See [CONTRIBUTING](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md) for how to contribute along
42
+ with some common problems to check out before creating an issue.
40
43
 
41
44
  *Questions, Problems, Suggestions, etc.*
42
45
 
43
- * [Mailing List](https://groups.google.com/forum/#!forum/simplecov) "Open mailing list for discussion and announcements on Google Groups"
46
+ * [Mailing List](https://groups.google.com/forum/#!forum/simplecov) "Open mailing list for discussion and announcements
47
+ on Google Groups"
44
48
 
45
49
  Getting started
46
50
  ---------------
47
51
  1. Add SimpleCov to your `Gemfile` and `bundle install`:
48
52
 
49
53
  ```ruby
50
- gem 'simplecov', :require => false, :group => :test
54
+ gem 'simplecov', require: false, group: :test
51
55
  ```
52
56
  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
57
+ (*or `spec_helper.rb`, `rails_helper`, cucumber `env.rb`, or whatever your preferred test
54
58
  framework uses*):
55
59
 
56
60
  ```ruby
@@ -70,8 +74,8 @@ Getting started
70
74
  endpoint) via a separate test process (e.g. when using Selenium) where you
71
75
  want to see all code executed by the `rails server`, and not just code
72
76
  executed in your actual test files, you'll want to add something like this
73
- to the top of `script/rails` (or `bin/rails` for Rails 4), but below the
74
- "shebang" line (`#! /usr/bin/env ruby`):
77
+ to the top of `bin/rails`, but below the "shebang" line (`#! /usr/bin/env
78
+ ruby`):
75
79
 
76
80
  ```ruby
77
81
  if ENV['RAILS_ENV'] == 'test'
@@ -81,23 +85,41 @@ Getting started
81
85
  end
82
86
  ```
83
87
 
84
- 3. Run your tests, open up `coverage/index.html` in your browser and check out
85
- what you've missed so far.
86
- 4. Add the following to your `.gitignore` file to ensure that coverage results
88
+ 3. Run your full test suite to see the percent coverage that your application has.
89
+ 4. After running your tests, open `coverage/index.html` in the browser of your choice. For example, in a Mac Terminal,
90
+ run the following command from your application's root directory:
91
+
92
+ ```
93
+ open coverage/index.html
94
+ ```
95
+ in a debian/ubuntu Terminal,
96
+
97
+ ```
98
+ xdg-open coverage/index.html
99
+ ```
100
+
101
+ **Note:** [This guide](https://dwheeler.com/essays/open-files-urls.html) can help if you're unsure which command your particular
102
+ operating system requires.
103
+
104
+ 5. Add the following to your `.gitignore` file to ensure that coverage results
87
105
  are not tracked by Git (optional):
88
106
 
89
- ```
90
- coverage
91
- ```
107
+ ```
108
+ echo "coverage" >> .gitignore
109
+ ```
110
+ Or if you use Windows:
111
+ ```
112
+ echo coverage >> .gitignore
113
+ ```
92
114
 
93
- If you're making a Rails application, SimpleCov comes with built-in configurations (see below for information on profiles)
94
- that will get you started with groups for your Controllers, Views, Models and Helpers. To use it, the first two lines of
95
- your test_helper should be like this:
115
+ If you're making a Rails application, SimpleCov comes with built-in configurations (see below for information on
116
+ profiles) that will get you started with groups for your Controllers, Models and Helpers. To use it, the
117
+ first two lines of your test_helper should be like this:
96
118
 
97
- ```ruby
98
- require 'simplecov'
99
- SimpleCov.start 'rails'
100
- ```
119
+ ```ruby
120
+ require 'simplecov'
121
+ SimpleCov.start 'rails'
122
+ ```
101
123
 
102
124
  ## Example output
103
125
 
@@ -123,8 +145,9 @@ require 'simplecov'
123
145
  SimpleCov.start 'rails'
124
146
  ```
125
147
 
126
- You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov does not
127
- care what kind of framework it is running in; it just looks at what code is being executed and generates a report about it.
148
+ You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov
149
+ does not care what kind of framework it is running in; it just looks at what code is being executed and generates a
150
+ report about it.
128
151
 
129
152
  ### Notes on specific frameworks and test utilities
130
153
 
@@ -135,28 +158,28 @@ to use SimpleCov with them. Here's an overview of the known ones:
135
158
  <tr><th>Framework</th><th>Notes</th><th>Issue</th></tr>
136
159
  <tr>
137
160
  <th>
138
- bootsnap
161
+ parallel_tests
139
162
  </th>
140
163
  <td>
141
- <a href="#want-to-use-bootsnap-with-simplecov">See section below.</a>
164
+ As of 0.8.0, SimpleCov should correctly recognize parallel_tests and
165
+ supplement your test suite names with their corresponding test env
166
+ numbers. SimpleCov locks the resultset cache while merging, ensuring no
167
+ race conditions occur when results are merged.
142
168
  </td>
143
169
  <td>
144
- <a href="https://github.com/Shopify/bootsnap/issues/35">Shopify/bootsnap#35</a>
170
+ <a href="https://github.com/colszowka/simplecov/issues/64">#64</a> &amp;
171
+ <a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
145
172
  </td>
146
173
  </tr>
147
174
  <tr>
148
175
  <th>
149
- parallel_tests
176
+ knapsack_pro
150
177
  </th>
151
178
  <td>
152
- As of 0.8.0, SimpleCov should correctly recognize parallel_tests and
153
- supplement your test suite names with their corresponding test env
154
- numbers. SimpleCov locks the resultset cache while merging, ensuring no
155
- race conditions occur when results are merged.
179
+ To make SimpleCov work with Knapsack Pro Queue Mode to split tests in parallel on CI jobs you need to provide CI node index number to the <code>SimpleCov.command_name</code> in <code>KnapsackPro::Hooks::Queue.before_queue</code> hook.
156
180
  </td>
157
181
  <td>
158
- <a href="https://github.com/colszowka/simplecov/issues/64">#64</a> &amp;
159
- <a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
182
+ <a href="https://knapsackpro.com/faq/question/how-to-use-simplecov-in-queue-mode">Tip</a>
160
183
  </td>
161
184
  </tr>
162
185
  <tr>
@@ -230,7 +253,8 @@ to use SimpleCov with them. Here's an overview of the known ones:
230
253
  ```ruby
231
254
  SimpleCov.some_config_option 'foo'
232
255
  ```
233
- * If you do not want to start coverage immediately after launch or want to add additional configuration later on in a concise way, use:
256
+ * If you do not want to start coverage immediately after launch or want to add additional configuration later on in a
257
+ concise way, use:
234
258
 
235
259
  ```ruby
236
260
  SimpleCov.configure do
@@ -242,11 +266,12 @@ Please check out the [Configuration] API documentation to find out what you can
242
266
 
243
267
  ## Using .simplecov for centralized config
244
268
 
245
- If you use SimpleCov to merge multiple test suite results (e.g. Test/Unit and Cucumber) into a single report, you'd normally have to
246
- set up all your config options twice, once in `test_helper.rb` and once in `env.rb`.
269
+ If you use SimpleCov to merge multiple test suite results (e.g. Test/Unit and Cucumber) into a single report, you'd
270
+ normally have to set up all your config options twice, once in `test_helper.rb` and once in `env.rb`.
247
271
 
248
- To avoid this, you can place a file called `.simplecov` in your project root. You can then just leave the `require 'simplecov'` in each
249
- test setup helper and move the `SimpleCov.start` code with all your custom config options into `.simplecov`:
272
+ To avoid this, you can place a file called `.simplecov` in your project root. You can then just leave the
273
+ `require 'simplecov'` in each test setup helper (**at the top**) and move the `SimpleCov.start` code with all your
274
+ custom config options into `.simplecov`:
250
275
 
251
276
  ```ruby
252
277
  # test/test_helper.rb
@@ -260,21 +285,74 @@ SimpleCov.start 'rails' do
260
285
  # any custom configs like groups and filters can be here at a central place
261
286
  end
262
287
  ```
263
- Using `.simplecov` rather than separately requiring SimpleCov multiple times is recommended if you are merging multiple test frameworks like Cucumber and RSpec that rely on each other, as invoking SimpleCov multiple times can cause coverage information to be lost.
288
+
289
+ Using `.simplecov` rather than separately requiring SimpleCov multiple times is recommended if you are merging multiple
290
+ test frameworks like Cucumber and RSpec that rely on each other, as invoking SimpleCov multiple times can cause coverage
291
+ information to be lost.
292
+
293
+ ## Branch coverage (ruby "~> 2.5")
294
+ Add branch coverage measurement statistics to your results. Supported in CRuby versions 2.5+.
295
+
296
+ ```ruby
297
+ # or in configure or just SimpleCov.enable_coverage :branch
298
+ SimpleCov.start do
299
+ enable_coverage :branch
300
+ end
301
+ ```
302
+
303
+ Branch coverage is a feature introduced in Ruby 2.5 concerning itself with whether a
304
+ particular branch of a condition had been executed. Line coverage on the other hand
305
+ is only interested in whether a line of code has been executed.
306
+
307
+ This comes in handy for instance for one line conditionals:
308
+
309
+ ```ruby
310
+ number.odd? ? "odd" : "even"
311
+ ```
312
+
313
+ In line coverage this line would always be marked as executed but you'd never know if both
314
+ conditions were met. Guard clauses have a similar story:
315
+
316
+ ```ruby
317
+ return if number.odd?
318
+
319
+ # more code
320
+ ```
321
+
322
+ If all the code in that method was covered you'd never know if the guard clause was ever
323
+ triggered! With line coverage as just evaluating the condition marks it as covered.
324
+
325
+ In the HTML report the lines of code will be annotated like `branch_type: hit_count`:
326
+
327
+ * `then: 2` - the then branch (of an `if`) was executed twice
328
+ * `else: 0` - the else branch (of an `if` or `case`) was never executed
329
+
330
+ Not that even if you don't declare an `else` branch it will still show up in the coverage
331
+ reports meaning that the condition of the `if` was not hit or that no `when` of `case`
332
+ was hit during the test runs.
333
+
334
+ **Is branch coverage strictly better?** No. Branch coverage really only concerns itself with
335
+ conditionals - meaning coverage of sequential code is of no interest to it. A file without
336
+ conditional logic will have no branch coverage data and SimpleCov will report 0 of 0
337
+ branches covered as 100% (as everything that can be covered was covered).
338
+
339
+ Hence, we recommend looking at both metrics together. Branch coverage might also be a good
340
+ overall metric to look at - while you might be missing only 10% of your lines that might
341
+ account for 50% of your branches for instance.
264
342
 
265
343
  ## Filters
266
344
 
267
- Filters can be used to remove selected files from your coverage data. By default, a filter is applied that removes all files
268
- OUTSIDE of your project's root directory - otherwise you'd end up with billions of coverage reports for source files in the
269
- gems you are using.
345
+ Filters can be used to remove selected files from your coverage data. By default, a filter is applied that removes all
346
+ files OUTSIDE of your project's root directory - otherwise you'd end up with billions of coverage reports for source
347
+ files in the gems you are using.
270
348
 
271
349
  You can define your own to remove things like configuration files, tests or whatever you don't need in your coverage
272
350
  report.
273
351
 
274
352
  ### Defining custom filters
275
353
 
276
- You can currently define a filter using either a String or Regexp (that will then be Regexp-matched against each source file's path),
277
- a block or by passing in your own Filter class.
354
+ You can currently define a filter using either a String or Regexp (that will then be Regexp-matched against each source
355
+ file's path), a block or by passing in your own Filter class.
278
356
 
279
357
  #### String filter
280
358
 
@@ -306,9 +384,10 @@ SimpleCov.start do
306
384
  end
307
385
  ```
308
386
 
309
- Block filters receive a SimpleCov::SourceFile instance and expect your block to return either true (if the file is to be removed
310
- from the result) or false (if the result should be kept). Please check out the RDoc for SimpleCov::SourceFile to learn about the
311
- methods available to you. In the above example, the filter will remove all files that have less than 5 lines of code.
387
+ Block filters receive a SimpleCov::SourceFile instance and expect your block to return either true (if the file is to be
388
+ removed from the result) or false (if the result should be kept). Please check out the RDoc for SimpleCov::SourceFile to
389
+ learn about the methods available to you. In the above example, the filter will remove all files that have less than 5
390
+ lines of code.
312
391
 
313
392
  #### Custom filter class
314
393
 
@@ -322,9 +401,10 @@ end
322
401
  SimpleCov.add_filter LineFilter.new(5)
323
402
  ```
324
403
 
325
- Defining your own filters is pretty easy: Just inherit from SimpleCov::Filter and define a method 'matches?(source_file)'. When running
326
- the filter, a true return value from this method will result in the removal of the given source_file. The filter_argument method
327
- is being set in the SimpleCov::Filter initialize method and thus is set to 5 in this example.
404
+ Defining your own filters is pretty easy: Just inherit from SimpleCov::Filter and define a method
405
+ 'matches?(source_file)'. When running the filter, a true return value from this method will result in the removal of the
406
+ given source_file. The filter_argument method is being set in the SimpleCov::Filter initialize method and thus is set to
407
+ 5 in this example.
328
408
 
329
409
  #### Array filter
330
410
 
@@ -351,7 +431,9 @@ end
351
431
 
352
432
  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
433
 
354
- **Note:** You shouldn't have to use the nocov token to skip private methods that are being included in your coverage. If you appropriately test the public interface of your classes and objects you should automatically get full coverage of your private methods.
434
+ **Note:** You shouldn't have to use the nocov token to skip private methods that are being included in your coverage. If
435
+ you appropriately test the public interface of your classes and objects you should automatically get full coverage of
436
+ your private methods.
355
437
 
356
438
  ## Default root filter and coverage for things outside of it
357
439
 
@@ -374,8 +456,8 @@ end
374
456
 
375
457
  You can separate your source files into groups. For example, in a Rails app, you'll want to have separate listings for
376
458
  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 results,
378
- which exclude files from results when the filter results in a true value.
459
+ filter classes), but source files end up in a group when the filter passes (returns true), as opposed to filtering
460
+ results, which exclude files from results when the filter results in a true value.
379
461
 
380
462
  Add your groups with:
381
463
 
@@ -395,12 +477,11 @@ end
395
477
 
396
478
  You normally want to have your coverage analyzed across ALL of your test suites, right?
397
479
 
398
- Simplecov automatically caches coverage results in your (coverage_path)/.resultset.json. Those results will then
399
- be automatically merged when generating the result, so when coverage is set up properly for Cucumber and your
400
- unit / functional / integration tests, all of those test suites will be taken into account when building the
401
- coverage report.
402
-
403
- There are two things to note here though:
480
+ Simplecov automatically caches coverage results in your
481
+ (coverage_path)/.resultset.json, and will merge or override those with
482
+ subsequent runs, depending on whether simplecov considers those subsequent runs
483
+ as different test suites or as the same test suite as the cached results. To
484
+ make this distinction, simplecov has the concept of "test suite names".
404
485
 
405
486
  ### Test suite names
406
487
 
@@ -454,24 +535,96 @@ SimpleCov.command_name "features" + (ENV['TEST_ENV_NUMBER'] || '')
454
535
 
455
536
  [simplecov-html] prints the used test suites in the footer of the generated coverage report.
456
537
 
457
- ### Timeout for merge
458
538
 
459
- Of course, your cached coverage data is likely to become invalid at some point. Thus, result sets that are older than
460
- `SimpleCov.merge_timeout` will not be used any more. By default, the timeout is 600 seconds (10 minutes), and you can
461
- raise (or lower) it by specifying `SimpleCov.merge_timeout 3600` (1 hour), or, inside a configure/start block, with
462
- just `merge_timeout 3600`.
539
+ ### Merging test runs under the same execution environment
540
+
541
+ Test results are automatically merged with previous runs in the same execution
542
+ environment when generating the result, so when coverage is set up properly for
543
+ Cucumber and your unit / functional / integration tests, all of those test
544
+ suites will be taken into account when building the coverage report.
545
+
546
+ #### Timeout for merge
547
+
548
+ Of course, your cached coverage data is likely to become invalid at some point. Thus, when automatically merging
549
+ subsequent test runs, result sets that are older than `SimpleCov.merge_timeout` will not be used any more. By default,
550
+ the timeout is 600 seconds (10 minutes), and you can raise (or lower) it by specifying `SimpleCov.merge_timeout 3600`
551
+ (1 hour), or, inside a configure/start block, with just `merge_timeout 3600`.
552
+
553
+ You can deactivate this automatic merging altogether with `SimpleCov.use_merging false`.
554
+
555
+ ### Merging test runs under different execution environments
556
+
557
+ If your tests are done in parallel across multiple build machines, you can fetch them all and merge them into a single
558
+ result set using the `SimpleCov.collate` method. This can be added to a Rakefile or script file, having downloaded a set of
559
+ `.resultset.json` files from each parallel test run.
560
+
561
+ ```ruby
562
+ # lib/tasks/coverage_report.rake
563
+ namespace :coverage do
564
+ desc "Collates all result sets generated by the different test runners"
565
+ task :report do
566
+ require 'simplecov'
567
+
568
+ SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"]
569
+ end
570
+ end
571
+ ```
572
+
573
+ `SimpleCov.collate` also takes an optional simplecov profile and an optional
574
+ block for configuration, just the same as `SimpleCov.start` or
575
+ `SimpleCov.configure`. This means you can configure a separate formatter for
576
+ the collated output. For instance, you can make the formatter in
577
+ `SimpleCov.start` the `SimpleCov::Formatter::SimpleFormatter`, and only use more
578
+ complex formatters in the final `SimpleCov.collate` run.
579
+
580
+ ```ruby
581
+ # spec/spec_helper.rb
582
+ require 'simplecov'
583
+
584
+ SimpleCov.start 'rails' do
585
+ # Disambiguates individual test runs
586
+ command_name "Job #{ENV["TEST_ENV_NUMBER"]}" if ENV["TEST_ENV_NUMBER"]
587
+
588
+ if ENV['CI']
589
+ formatter SimpleCov::Formatter::SimpleFormatter
590
+ else
591
+ formatter SimpleCov::Formatter::MultiFormatter.new([
592
+ SimpleCov::Formatter::SimpleFormatter,
593
+ SimpleCov::Formatter::HTMLFormatter
594
+ ])
595
+ end
596
+
597
+ track_files "**/*.rb"
598
+ end
599
+ ```
600
+
601
+ ```ruby
602
+ # lib/tasks/coverage_report.rake
603
+ namespace :coverage do
604
+ task :report do
605
+ require 'simplecov'
463
606
 
464
- You can deactivate merging altogether with `SimpleCov.use_merging false`.
607
+ SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"], 'rails' do
608
+ formatter SimpleCov::Formatter::MultiFormatter.new([
609
+ SimpleCov::Formatter::SimpleFormatter,
610
+ SimpleCov::Formatter::HTMLFormatter
611
+ ])
612
+ end
613
+ end
614
+ end
615
+ ```
465
616
 
466
617
  ## Running coverage only on demand
467
618
 
468
- The Ruby STDLIB Coverage library that SimpleCov builds upon is *very* fast (on a ~10 min Rails test suite, the speed drop was
469
- only a couple seconds for me), and therefore it's SimpleCov's policy to just generate coverage every time you run your tests because
470
- it doesn't do your test speed any harm and you're always equipped with the latest and greatest coverage results.
619
+ The Ruby STDLIB Coverage library that SimpleCov builds upon is *very* fast (on a ~10 min Rails test suite, the speed
620
+ drop was only a couple seconds for me), and therefore it's SimpleCov's policy to just generate coverage every time you
621
+ run your tests because it doesn't do your test speed any harm and you're always equipped with the latest and greatest
622
+ coverage results.
471
623
 
472
624
  Because of this, SimpleCov has no explicit built-in mechanism to run coverage only on demand.
473
625
 
474
- However, you can still accomplish this very easily by introducing an ENV variable conditional into your SimpleCov setup block, like this:
626
+ However, you can still accomplish this very easily by introducing an ENV variable conditional into your SimpleCov setup
627
+ block, like this:
475
628
 
476
629
  ```ruby
477
630
  SimpleCov.start if ENV["COVERAGE"]
@@ -483,6 +636,21 @@ Then, SimpleCov will only run if you execute your tests like this:
483
636
  COVERAGE=true rake test
484
637
  ```
485
638
 
639
+ ## Errors and exit statuses
640
+
641
+ To aid in debugging issues, if an error is raised, SimpleCov will print a message to `STDERR`
642
+ with the exit status of the error, like:
643
+
644
+ ```
645
+ SimpleCov failed with exit 1
646
+ ```
647
+
648
+ This `STDERR` message can be disabled with:
649
+
650
+ ```
651
+ SimpleCov.print_error_status = false
652
+ ```
653
+
486
654
  ## Profiles
487
655
 
488
656
  By default, SimpleCov's only config assumption is that you only want coverage reports for files inside your project
@@ -520,8 +688,8 @@ end
520
688
 
521
689
  ### Custom profiles
522
690
 
523
- You can load additional profiles with the SimpleCov.load_profile('xyz') method. This allows you to build upon an existing
524
- profile and customize it so you can reuse it in unit tests and Cucumber features. For example:
691
+ You can load additional profiles with the SimpleCov.load_profile('xyz') method. This allows you to build upon an
692
+ existing profile and customize it so you can reuse it in unit tests and Cucumber features. For example:
525
693
 
526
694
  ```ruby
527
695
  # lib/simplecov_custom_profile.rb
@@ -562,7 +730,8 @@ SimpleCov.minimum_coverage 90
562
730
 
563
731
  ### Minimum coverage by file
564
732
 
565
- You can define the minimum coverage by file percentage expected. SimpleCov will return non-zero if unmet. This is useful to help ensure coverage is relatively consistent, rather than being skewed by particularly good or bad areas of the code.
733
+ You can define the minimum coverage by file percentage expected. SimpleCov will return non-zero if unmet. This is useful
734
+ to help ensure coverage is relatively consistent, rather than being skewed by particularly good or bad areas of the code.
566
735
 
567
736
  ```ruby
568
737
  SimpleCov.minimum_coverage_by_file 80
@@ -592,8 +761,8 @@ You can use your own formatter with:
592
761
  SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
593
762
  ```
594
763
 
595
- When calling SimpleCov.result.format!, it will be invoked with SimpleCov::Formatter::YourFormatter.new.format(result), "result"
596
- being an instance of SimpleCov::Result. Do whatever your wish with that!
764
+ When calling SimpleCov.result.format!, it will be invoked with SimpleCov::Formatter::YourFormatter.new.format(result),
765
+ "result" being an instance of SimpleCov::Result. Do whatever your wish with that!
597
766
 
598
767
 
599
768
  ## Using multiple formatters
@@ -615,11 +784,9 @@ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
615
784
 
616
785
  ## Ruby version compatibility
617
786
 
618
- Only Ruby 1.9+ ships with the coverage library that SimpleCov depends upon and that's what SimpleCov supports. Additionally JRuby 9.1+ is supported as well, while JRuby 1.7 and 9.0 should work they're not "officially" supported.
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.
787
+ SimpleCov is built in [Continuous Integration] on Ruby 2.4+ as well as JRuby 9.2+.
621
788
 
622
- SimpleCov is built in [Continuous Integration] on Ruby 1.9.3, 2.0.0, 2.1, 2.2, 2.3, 2.4 as well as JRuby 9.1.
789
+ Note for JRuby => You need to pass JRUBY_OPTS="--debug" or create .jrubyrc and add debug.fullTrace=true
623
790
 
624
791
  ## Want to find dead code in production?
625
792
 
@@ -627,49 +794,68 @@ Try [Coverband](https://github.com/danmayer/coverband).
627
794
 
628
795
  ## Want to use Spring with SimpleCov?
629
796
 
630
- If you're using [Spring](https://github.com/rails/spring) to speed up test suite runs and want to run SimpleCov along with them, you'll find that it often misreports coverage with the default config due to some sort of eager loading issue. Don't despair!
797
+ If you're using [Spring](https://github.com/rails/spring) to speed up test suite runs and want to run SimpleCov along
798
+ with them, you'll find that it often misreports coverage with the default config due to some sort of eager loading
799
+ issue. Don't despair!
631
800
 
632
- 1. Change the following settings in `test.rb`.
801
+ One solution is to [explicitly call eager
802
+ load](https://github.com/colszowka/simplecov/issues/381#issuecomment-347651728)
803
+ in your `test_helper.rb` / `spec_helper.rb` after calling `SimpleCov.start`.
633
804
 
634
- ```ruby
635
- # For Rails 4 or earlier, use the following configuration:
636
- # Disable Rails's static asset server (Apache or nginx will already do this)
637
- config.serve_static_files = false
638
- config.eager_load = false
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:
805
+ ```ruby
806
+ require 'simplecov'
807
+ SimpleCov.start 'rails'
808
+ Rails.application.eager_load!
809
+ ```
649
810
 
650
- ```ruby
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?
811
+ Alternatively, you could disable Spring while running SimpleCov:
812
+
813
+ ```
814
+ DISABLE_SPRING=1 rake test
815
+ ```
816
+
817
+ Or you could remove `gem 'spring'` from your `Gemfile`.
818
+
819
+ ## Troubleshooting
660
820
 
661
- As mentioned in [this issue](https://github.com/Shopify/bootsnap/issues/35) iseq
662
- loading/dumping doesn't work with coverage. Hence you need to deactivate it when
663
- you run coverage so for instance when you use the environment `COVERAGE=true` to
664
- decide that you want to gather coverage you can do:
821
+ The **most common problem is that simplecov isn't required and started before everything else**. In order to track
822
+ coverage for your whole application **simplecov needs to be the first one** so that it (and the underlying coverage
823
+ library) can subsequently track loaded files and their usage.
824
+
825
+ If you are missing coverage for some code a simple trick is to put a puts statement in there and right after
826
+ `SimpleCov.start` so you can see if the file really was loaded after simplecov was started.
665
827
 
666
828
  ```ruby
667
- Bootsnap.setup(
668
- compile_cache_iseq: !ENV["COVERAGE"], # Compile Ruby code into ISeq cache, breaks coverage reporting.
669
- # all those other options
670
- )
829
+ # my_code.rb
830
+ class MyCode
831
+
832
+ puts "MyCode is being loaded!"
833
+
834
+ def my_method
835
+ # ...
836
+ end
837
+ end
838
+
839
+ # spec_helper.rb/rails_helper.rb/test_helper.rb/.simplecov whatever
840
+
841
+ SimpleCov.start
842
+ puts "SimpleCov started successfully!"
671
843
  ```
672
844
 
845
+ Now when you run your test suite and you see:
846
+
847
+ ```
848
+ SimpleCov started successfully!
849
+ MyCode is being loaded!
850
+ ```
851
+
852
+ then it's good otherwise you likely have a problem :)
853
+
854
+ ## Code of Conduct
855
+
856
+ Everyone participating in this project's development, issue trackers and other channels is expected to follow our
857
+ [Code of Conduct](./CODE_OF_CONDUCT.md)
858
+
673
859
  ## Contributing
674
860
 
675
861
  See the [contributing guide](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md).