danger-jacoco-instacart 0.1.9 → 0.1.12.SNAPSHOT.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardoc/checksums +15 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +1 -0
- data/lib/jacoco/gem_version.rb +1 -1
- data/lib/jacoco/plugin.rb +90 -24
- data/spec/fixtures/output_a.xml +1 -1
- data/spec/fixtures/output_b.xml +0 -2
- data/spec/fixtures/output_c.xml +73 -0
- data/spec/fixtures/output_d.xml +35 -0
- data/spec/fixtures/output_e.xml +34 -0
- data/spec/fixtures/output_f.xml +33 -0
- data/spec/jacoco_spec.rb +202 -17
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b68f00cbed8e16eb566459431cfb6d296b84b2fec8b87f5e07cb40e513b08b1c
|
4
|
+
data.tar.gz: a14e683220953972e2ee3fa84ff6f4fd795c60701c8108d187a24f710b10eced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a8ed5dfd7cf494b6e1ceb45f87d06d8666e6f92ec1e31b73a75bdf00a2cc209c67854d3d0eee1eb367b4311ac280a22115fb075d904538f611ccb44ac94d5e7
|
7
|
+
data.tar.gz: 6c2cc47baf7fea31de40f60b531a442a5daad3460b2ecf6360dc6e1860077a4888fff6e9e071c0d4775c87224533e66edf1483586418220953762ed76621399a
|
data/.yardoc/checksums
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_jacoco.rb 38229d934b3315bb2a5a4eec18eb65f3c54d304f
|
2
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb 4109fe221b49a7d872a2d1bebf772583ed7c4437
|
3
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb 17233d007f6187a47676390d6499ab5c7cb3a2b8
|
4
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/sax_parser.rb 370e2799f8dbdf7d642c820214e6ea84c30c9cb0
|
5
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/counter.rb 368f4a9811617b7a174ddf837a8fac49a4bc32a6
|
6
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/report.rb 7cf45ee71ff347a130320f6190ddb25525c7095d
|
7
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/class.rb 89c78fdda05e07a709ddfb1d5ae9fb2472eaa504
|
8
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/method.rb 37076c751eb37683c0071c154319b85a987a2708
|
9
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/group.rb 6a8ccb32c793842af49c5c2d0d015bf01b0ec537
|
10
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/sourcefile.rb 19ffc9500370f50807af91a6f177c42d5879aabd
|
11
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/session_info.rb 5c908a9f96bd054d202edfeb30f29dcb4b42a1c9
|
12
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/line.rb ff5d6fc5bf0bf808c46d4bafce0f3fc53c8fdd73
|
13
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/package.rb b865b8eca41323dfc832babc08179fb94b5dfb0f
|
14
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/dom_parser.rb d08e0ca8531dd04bc9261a57fc03852b23883965
|
15
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_plugin.rb f5f82beb7e326604e1003f368e15da243263c0cf
|
data/.yardoc/complete
ADDED
File without changes
|
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
Binary file
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ jacoco.minimum_class_coverage_map = { # optional (default is empty)
|
|
23
23
|
'com/package/more/specific/ClassName' => 15
|
24
24
|
}
|
25
25
|
jacoco.minimum_class_coverage_percentage = 75 # default 0
|
26
|
+
jacoco.only_check_new_files = true # default false
|
26
27
|
jacoco.files_extension = [".java"] # default [".kt", ".java"]
|
27
28
|
jacoco.report("path/to/jacoco.xml", "http://jacoco-html-reports/")
|
28
29
|
```
|
data/lib/jacoco/gem_version.rb
CHANGED
data/lib/jacoco/plugin.rb
CHANGED
@@ -20,17 +20,34 @@ module Danger
|
|
20
20
|
# @tags jacoco, coverage, java, android, kotlin
|
21
21
|
#
|
22
22
|
class DangerJacoco < Plugin # rubocop:disable Metrics/ClassLength
|
23
|
-
attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
|
24
|
-
:
|
23
|
+
attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
|
24
|
+
:minimum_composable_class_coverage_percentage, :only_check_new_files, :files_extension,
|
25
|
+
:minimum_package_coverage_map, :minimum_class_coverage_map, :fail_no_coverage_data_found,
|
26
|
+
:title, :class_column_title, :subtitle_success, :subtitle_failure
|
25
27
|
|
26
28
|
# Initialize the plugin with configured parameters or defaults
|
27
29
|
def setup
|
30
|
+
setup_minimum_coverages
|
31
|
+
setup_texts
|
32
|
+
@only_check_new_files = false unless only_check_new_files
|
33
|
+
@files_extension = ['.kt', '.java'] unless files_extension
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initialize the plugin with configured optional texts
|
37
|
+
def setup_texts
|
38
|
+
@title = 'JaCoCo' unless title
|
39
|
+
@class_column_title = 'Class' unless class_column_title
|
40
|
+
@subtitle_success = 'All classes meet coverage requirement. Well done! :white_check_mark:' unless subtitle_success
|
41
|
+
@subtitle_failure = 'There are classes that do not meet coverage requirement :warning:' unless subtitle_failure
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initialize the plugin with configured coverage minimum parameters or defaults
|
45
|
+
def setup_minimum_coverages
|
28
46
|
@minimum_project_coverage_percentage = 0 unless minimum_project_coverage_percentage
|
29
47
|
@minimum_class_coverage_percentage = 0 unless minimum_class_coverage_percentage
|
48
|
+
@minimum_composable_class_coverage_percentage = 0 unless minimum_composable_class_coverage_percentage
|
30
49
|
@minimum_package_coverage_map = {} unless minimum_package_coverage_map
|
31
50
|
@minimum_class_coverage_map = {} unless minimum_class_coverage_map
|
32
|
-
@files_extension = ['.kt', '.java'] unless files_extension
|
33
|
-
@title = 'JaCoCo' unless title
|
34
51
|
end
|
35
52
|
|
36
53
|
# Parses the xml output of jacoco to Ruby model classes
|
@@ -59,36 +76,48 @@ module Danger
|
|
59
76
|
# Java => blah/blah/java/slashed_package/Source.java
|
60
77
|
# Kotlin => blah/blah/kotlin/slashed_package/Source.kt
|
61
78
|
#
|
79
|
+
# rubocop:disable Style/AbcSize
|
62
80
|
def report(path, report_url = '', delimiter = %r{/java/|/kotlin/}, fail_no_coverage_data_found: true)
|
63
81
|
@fail_no_coverage_data_found = fail_no_coverage_data_found
|
64
82
|
|
65
83
|
setup
|
66
|
-
|
84
|
+
class_to_file_path_hash = classes(delimiter)
|
85
|
+
classnames = class_to_file_path_hash.keys
|
67
86
|
|
68
|
-
parser = Jacoco::SAXParser.new(
|
87
|
+
parser = Jacoco::SAXParser.new(classnames)
|
69
88
|
Nokogiri::XML::SAX::Parser.new(parser).parse(File.open(path))
|
70
89
|
|
71
90
|
total_covered = total_coverage(path)
|
72
91
|
|
73
|
-
|
74
|
-
report_markdown
|
92
|
+
header = "### #{title} Code Coverage #{total_covered[:covered]}% #{total_covered[:status]}\n"
|
93
|
+
report_markdown = header
|
94
|
+
report_markdown += "| #{class_column_title} | Covered | Required | Status |\n"
|
75
95
|
report_markdown += "|:---|:---:|:---:|:---:|\n"
|
76
|
-
class_coverage_above_minimum = markdown_class(parser, report_markdown, report_url)
|
96
|
+
class_coverage_above_minimum = markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
97
|
+
subtitle = class_coverage_above_minimum ? subtitle_success : subtitle_failure
|
98
|
+
report_markdown.insert(header.length, "#### #{subtitle}\n")
|
77
99
|
markdown(report_markdown)
|
78
100
|
|
79
101
|
report_fails(class_coverage_above_minimum, total_covered)
|
80
102
|
end
|
103
|
+
# rubocop:enable Style/AbcSize
|
81
104
|
|
82
|
-
# Select modified and added files in this PR
|
105
|
+
# Select either only added files or modified and added files in this PR,
|
106
|
+
# depending on "only_check_new_files" attribute
|
83
107
|
def classes(delimiter)
|
84
108
|
git = @dangerfile.git
|
85
|
-
affected_files = git.
|
109
|
+
affected_files = only_check_new_files ? git.added_files : git.added_files + git.modified_files
|
110
|
+
class_to_file_path_hash = {}
|
86
111
|
affected_files.select { |file| files_extension.reduce(false) { |state, el| state || file.end_with?(el) } }
|
87
|
-
.
|
112
|
+
.each do |file| # "src/java/com/example/CachedRepository.java"
|
113
|
+
classname = file.split('.').first.split(delimiter)[1] # "com/example/CachedRepository"
|
114
|
+
class_to_file_path_hash[classname] = file
|
115
|
+
end
|
116
|
+
class_to_file_path_hash
|
88
117
|
end
|
89
118
|
|
90
119
|
# It returns a specific class code coverage and an emoji status as well
|
91
|
-
def report_class(jacoco_class)
|
120
|
+
def report_class(jacoco_class, file_path)
|
92
121
|
report_result = {
|
93
122
|
covered: 'No coverage data found : -',
|
94
123
|
status: ':black_joker:',
|
@@ -98,7 +127,7 @@ module Danger
|
|
98
127
|
counter = coverage_counter(jacoco_class)
|
99
128
|
unless counter.nil?
|
100
129
|
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
|
101
|
-
required_coverage = required_class_coverage(jacoco_class)
|
130
|
+
required_coverage = required_class_coverage(jacoco_class, file_path)
|
102
131
|
status = coverage_status(coverage, required_coverage)
|
103
132
|
|
104
133
|
report_result = {
|
@@ -112,13 +141,19 @@ module Danger
|
|
112
141
|
end
|
113
142
|
|
114
143
|
# Determines the required coverage for the class
|
115
|
-
|
144
|
+
# rubocop:disable Metrics/AbcSize
|
145
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
146
|
+
def required_class_coverage(jacoco_class, file_path)
|
116
147
|
key = minimum_class_coverage_map.keys.detect { |k| jacoco_class.name.match(k) } || jacoco_class.name
|
117
148
|
required_coverage = minimum_class_coverage_map[key]
|
149
|
+
includes_composables = File.read(file_path).include? '@Composable' if File.exist?(file_path)
|
150
|
+
required_coverage = minimum_composable_class_coverage_percentage if required_coverage.nil? && includes_composables
|
118
151
|
required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
|
119
152
|
required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
|
120
153
|
required_coverage
|
121
154
|
end
|
155
|
+
# rubocop:enable Metrics/AbcSize
|
156
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
122
157
|
|
123
158
|
# it returns the most suitable coverage by package name to class or nil
|
124
159
|
def package_coverage(class_name)
|
@@ -138,7 +173,8 @@ module Danger
|
|
138
173
|
def coverage_status(coverage, minimum_percentage)
|
139
174
|
if coverage < (minimum_percentage / 2) then ':skull:'
|
140
175
|
elsif coverage < minimum_percentage then ':warning:'
|
141
|
-
else
|
176
|
+
else
|
177
|
+
':white_check_mark:'
|
142
178
|
end
|
143
179
|
end
|
144
180
|
|
@@ -162,10 +198,8 @@ module Danger
|
|
162
198
|
private
|
163
199
|
|
164
200
|
def coverage_counter(jacoco_class)
|
165
|
-
|
166
|
-
|
167
|
-
line_counter = counters.detect { |e| e.type.eql? 'LINE' }
|
168
|
-
counter = branch_counter.nil? ? line_counter : branch_counter
|
201
|
+
all_class_counters = jacoco_class.counters
|
202
|
+
counter = class_counter(all_class_counters)
|
169
203
|
|
170
204
|
if counter.nil?
|
171
205
|
no_coverage_data_found_message = "No coverage data found for #{jacoco_class.name}"
|
@@ -178,24 +212,49 @@ module Danger
|
|
178
212
|
counter
|
179
213
|
end
|
180
214
|
|
215
|
+
def class_counter(all_class_counters)
|
216
|
+
instruction_counter = all_class_counters.detect { |e| e.type.eql? 'INSTRUCTION' }
|
217
|
+
branch_counter = all_class_counters.detect { |e| e.type.eql? 'BRANCH' }
|
218
|
+
line_counter = all_class_counters.detect { |e| e.type.eql? 'LINE' }
|
219
|
+
if !instruction_counter.nil?
|
220
|
+
instruction_counter
|
221
|
+
elsif !branch_counter.nil?
|
222
|
+
branch_counter
|
223
|
+
else
|
224
|
+
line_counter
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
181
228
|
# rubocop:disable Style/SignalException
|
182
229
|
def report_fails(class_coverage_above_minimum, total_covered)
|
230
|
+
total_failure_message = ''
|
183
231
|
if total_covered[:covered] < minimum_project_coverage_percentage
|
184
232
|
# fail danger if total coverage is smaller than minimum_project_coverage_percentage
|
185
233
|
covered = total_covered[:covered]
|
186
|
-
|
234
|
+
total_failure_message = "Total coverage of #{covered}%." \
|
235
|
+
" Improve this to at least #{minimum_project_coverage_percentage}%"
|
236
|
+
fail(total_failure_message)
|
237
|
+
# rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that raise is unreachable since priorly called "fail" raises by itself, but in fact "fail" is caught and handled)
|
238
|
+
raise CoverageRequirementsNotMetError, total_failure_message if class_coverage_above_minimum
|
239
|
+
# rubocop:enable Lint/UnreachableCode
|
187
240
|
end
|
188
241
|
|
189
242
|
return if class_coverage_above_minimum
|
190
243
|
|
191
|
-
|
244
|
+
class_failure_message = 'Class coverage is below minimum.' \
|
245
|
+
" Improve to at least #{minimum_class_coverage_percentage}%"
|
246
|
+
fail(class_failure_message)
|
247
|
+
# rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that raise is unreachable since priorly called "fail" raises by itself, but in fact "fail" is caught and handled)
|
248
|
+
raise CoverageRequirementsNotMetError, "#{total_failure_message}. #{class_failure_message}"
|
249
|
+
# rubocop:enable Lint/UnreachableCode
|
192
250
|
end
|
193
251
|
# rubocop:enable Style/SignalException
|
194
252
|
|
195
|
-
def markdown_class(parser, report_markdown, report_url)
|
253
|
+
def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
196
254
|
class_coverage_above_minimum = true
|
197
255
|
parser.classes.each do |jacoco_class| # Check metrics for each classes
|
198
|
-
|
256
|
+
file_path = class_to_file_path_hash[jacoco_class.name]
|
257
|
+
rp = report_class(jacoco_class, file_path)
|
199
258
|
rl = report_link(jacoco_class.name, report_url)
|
200
259
|
ln = "| #{rl} | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
|
201
260
|
report_markdown << ln
|
@@ -216,3 +275,10 @@ module Danger
|
|
216
275
|
end
|
217
276
|
end
|
218
277
|
end
|
278
|
+
|
279
|
+
# Exception that is being thrown when any of the coverage requirements aren't met
|
280
|
+
class CoverageRequirementsNotMetError < StandardError
|
281
|
+
def initialize(msg = 'Coverage requirements not met')
|
282
|
+
super
|
283
|
+
end
|
284
|
+
end
|
data/spec/fixtures/output_a.xml
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
11
11
|
<counter type="METHOD" missed="0" covered="1"/>
|
12
12
|
</method>
|
13
|
-
<counter type="INSTRUCTION" missed="
|
13
|
+
<counter type="INSTRUCTION" missed="46" covered="46"/>
|
14
14
|
<counter type="LINE" missed="0" covered="14"/>
|
15
15
|
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
16
16
|
<counter type="METHOD" missed="0" covered="7"/>
|
data/spec/fixtures/output_b.xml
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
10
|
<counter type="METHOD" missed="0" covered="1"/>
|
11
11
|
</method>
|
12
|
-
<counter type="INSTRUCTION" missed="0" covered="46"/>
|
13
12
|
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
13
|
<counter type="METHOD" missed="0" covered="7"/>
|
15
14
|
<counter type="CLASS" missed="0" covered="1"/>
|
@@ -17,7 +16,6 @@
|
|
17
16
|
<sourcefile name="CachedRepository.java">
|
18
17
|
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
19
18
|
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
20
|
-
<counter type="INSTRUCTION" missed="2" covered="98"/>
|
21
19
|
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
22
20
|
<counter type="METHOD" missed="2" covered="11"/>
|
23
21
|
<counter type="CLASS" missed="2" covered="4"/>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="LINE" missed="0" covered="5"/>
|
10
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
11
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
12
|
+
</method>
|
13
|
+
<counter type="INSTRUCTION" missed="46" covered="46"/>
|
14
|
+
<counter type="LINE" missed="0" covered="14"/>
|
15
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
16
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
17
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
18
|
+
<counter type="BRANCH" missed="2" covered="2" />
|
19
|
+
</class>
|
20
|
+
<sourcefile name="CachedRepository.java">
|
21
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
22
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
23
|
+
<counter type="INSTRUCTION" missed="2" covered="98"/>
|
24
|
+
<counter type="LINE" missed="2" covered="19"/>
|
25
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
26
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
27
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
28
|
+
</sourcefile>
|
29
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
30
|
+
<counter type="BRANCH" missed="4" covered="4"/>
|
31
|
+
<counter type="LINE" missed="24" covered="68"/>
|
32
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
33
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
34
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
35
|
+
</package>
|
36
|
+
<package name="io/sample">
|
37
|
+
<class name="io/sample/UseCase">
|
38
|
+
<method name="<init>" desc="()V" line="17">
|
39
|
+
<counter type="INSTRUCTION" missed="3" covered="8"/>
|
40
|
+
<counter type="LINE" missed="0" covered="7"/>
|
41
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
42
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
43
|
+
</method>
|
44
|
+
<counter type="INSTRUCTION" missed="18" covered="36"/>
|
45
|
+
<counter type="LINE" missed="0" covered="12"/>
|
46
|
+
<counter type="COMPLEXITY" missed="5" covered="8"/>
|
47
|
+
<counter type="METHOD" missed="0" covered="9"/>
|
48
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
49
|
+
<counter type="BRANCH" missed="1" covered="2" />
|
50
|
+
</class>
|
51
|
+
<sourcefile name="UseCase.java">
|
52
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
53
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
54
|
+
<counter type="INSTRUCTION" missed="2" covered="48"/>
|
55
|
+
<counter type="LINE" missed="2" covered="9"/>
|
56
|
+
<counter type="COMPLEXITY" missed="2" covered="8"/>
|
57
|
+
<counter type="METHOD" missed="2" covered="7"/>
|
58
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
59
|
+
</sourcefile>
|
60
|
+
<counter type="INSTRUCTION" missed="101" covered="201"/>
|
61
|
+
<counter type="BRANCH" missed="4" covered="4"/>
|
62
|
+
<counter type="LINE" missed="54" covered="78"/>
|
63
|
+
<counter type="COMPLEXITY" missed="21" covered="29"/>
|
64
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
65
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
66
|
+
</package>
|
67
|
+
<counter type="INSTRUCTION" missed="39399" covered="49321"/>
|
68
|
+
<counter type="BRANCH" missed="3463" covered="4039"/>
|
69
|
+
<counter type="LINE" missed="9611" covered="9974"/>
|
70
|
+
<counter type="COMPLEXITY" missed="5517" covered="6444"/>
|
71
|
+
<counter type="METHOD" missed="3382" covered="4120"/>
|
72
|
+
<counter type="CLASS" missed="491" covered="570"/>
|
73
|
+
</report>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="INSTRUCTION" missed="46" covered="118"/>
|
13
|
+
<counter type="LINE" missed="1" covered="14"/>
|
14
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
15
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
16
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
17
|
+
<counter type="BRANCH" missed="2" covered="3" />
|
18
|
+
</class>
|
19
|
+
<sourcefile name="CachedRepository.java">
|
20
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
21
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
22
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
23
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
24
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
25
|
+
</sourcefile>
|
26
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
27
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
28
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
29
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
30
|
+
</package>
|
31
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
32
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
33
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
34
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
35
|
+
</report>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="LINE" missed="1" covered="14"/>
|
13
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
15
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
16
|
+
<counter type="BRANCH" missed="4" covered="3" />
|
17
|
+
</class>
|
18
|
+
<sourcefile name="CachedRepository.java">
|
19
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
20
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
21
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
22
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
23
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
24
|
+
</sourcefile>
|
25
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
26
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
27
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
28
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
29
|
+
</package>
|
30
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
31
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
32
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
33
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
34
|
+
</report>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="LINE" missed="1" covered="14"/>
|
13
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
15
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
16
|
+
</class>
|
17
|
+
<sourcefile name="CachedRepository.java">
|
18
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
19
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
20
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
21
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
22
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
23
|
+
</sourcefile>
|
24
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
25
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
26
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
27
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
28
|
+
</package>
|
29
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
30
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
31
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
32
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
33
|
+
</report>
|
data/spec/jacoco_spec.rb
CHANGED
@@ -21,7 +21,7 @@ module Danger
|
|
21
21
|
@my_plugin = @dangerfile.jacoco
|
22
22
|
|
23
23
|
modified_files = ['src/java/com/example/CachedRepository.java']
|
24
|
-
added_files = ['src/java/
|
24
|
+
added_files = ['src/java/io/sample/UseCase.java']
|
25
25
|
|
26
26
|
allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
|
27
27
|
allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
|
@@ -33,12 +33,12 @@ module Danger
|
|
33
33
|
@my_plugin.minimum_project_coverage_percentage = 50
|
34
34
|
@my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 100 }
|
35
35
|
|
36
|
-
@my_plugin.report
|
36
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 0%/)
|
37
37
|
|
38
38
|
expect(@dangerfile.status_report[:errors]).to eq(['Total coverage of 32.9%. Improve this to at least 50%',
|
39
39
|
'Class coverage is below minimum. Improve to at least 0%'])
|
40
40
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 32.9% :warning:')
|
41
|
-
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered |
|
41
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
42
42
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
43
43
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
|
44
44
|
end
|
@@ -49,8 +49,7 @@ module Danger
|
|
49
49
|
@my_plugin.minimum_project_coverage_percentage = 50
|
50
50
|
@my_plugin.minimum_class_coverage_map = { '.*Repository' => 60 }
|
51
51
|
|
52
|
-
@my_plugin.report
|
53
|
-
|
52
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 0%/)
|
54
53
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 60% | :warning: |')
|
55
54
|
end
|
56
55
|
|
@@ -60,8 +59,7 @@ module Danger
|
|
60
59
|
@my_plugin.minimum_project_coverage_percentage = 50
|
61
60
|
@my_plugin.minimum_package_coverage_map = { 'com/example/' => 70 }
|
62
61
|
|
63
|
-
@my_plugin.report
|
64
|
-
|
62
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
|
65
63
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 70% | :warning: |')
|
66
64
|
end
|
67
65
|
|
@@ -74,8 +72,7 @@ module Danger
|
|
74
72
|
'com/' => 90
|
75
73
|
}
|
76
74
|
|
77
|
-
@my_plugin.report
|
78
|
-
|
75
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
|
79
76
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 70% | :warning: |')
|
80
77
|
end
|
81
78
|
|
@@ -88,8 +85,7 @@ module Danger
|
|
88
85
|
'com/' => 30
|
89
86
|
}
|
90
87
|
|
91
|
-
@my_plugin.report
|
92
|
-
|
88
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
|
93
89
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 77% | :warning: |')
|
94
90
|
end
|
95
91
|
|
@@ -103,12 +99,11 @@ module Danger
|
|
103
99
|
}
|
104
100
|
@my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 100 }
|
105
101
|
|
106
|
-
@my_plugin.report
|
107
|
-
|
102
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
|
108
103
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
|
109
104
|
end
|
110
105
|
|
111
|
-
it 'test with overlapped package coverage and
|
106
|
+
it 'test with overlapped package coverage and lower class coverage' do
|
112
107
|
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
113
108
|
|
114
109
|
@my_plugin.minimum_project_coverage_percentage = 50
|
@@ -118,9 +113,50 @@ module Danger
|
|
118
113
|
}
|
119
114
|
@my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 80 }
|
120
115
|
|
116
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
|
117
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 80% | :warning: |')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'checks modified files when "only_check_new_files" attribute is false' do
|
121
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
122
|
+
|
123
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
124
|
+
@my_plugin.only_check_new_files = false
|
125
|
+
|
121
126
|
@my_plugin.report path_a
|
122
127
|
|
123
|
-
expect(@dangerfile.status_report[:markdowns][0].message).to include('
|
128
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
|
129
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
130
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
131
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 0% | :white_check_mark: |')
|
132
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'defaults "only_check_new_files" attribute to false' do
|
136
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
137
|
+
|
138
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
139
|
+
|
140
|
+
@my_plugin.report path_a
|
141
|
+
|
142
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 0% | :white_check_mark: |')
|
143
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'does _not_ check modified files when "only_check_new_files" attribute is true' do
|
147
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
148
|
+
|
149
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
150
|
+
@my_plugin.minimum_class_coverage_percentage = 70
|
151
|
+
@my_plugin.only_check_new_files = true
|
152
|
+
|
153
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 70%/)
|
154
|
+
|
155
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
|
156
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
157
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
158
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 70% | :warning: |')
|
159
|
+
expect(@dangerfile.status_report[:markdowns][0].message).not_to include('com/example/CachedRepository')
|
124
160
|
end
|
125
161
|
|
126
162
|
it 'adds a link to report' do
|
@@ -129,8 +165,7 @@ module Danger
|
|
129
165
|
@my_plugin.minimum_class_coverage_percentage = 80
|
130
166
|
@my_plugin.minimum_project_coverage_percentage = 50
|
131
167
|
|
132
|
-
@my_plugin.report(path_a, 'http://test.com/')
|
133
|
-
|
168
|
+
expect { @my_plugin.report(path_a, 'http://test.com/') }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 80%/)
|
134
169
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| [`com/example/CachedRepository`](http://test.com/com.example/CachedRepository.html) | 50% | 80% | :warning: |')
|
135
170
|
end
|
136
171
|
|
@@ -169,6 +204,156 @@ module Danger
|
|
169
204
|
|
170
205
|
expect { @my_plugin.report path_a, fail_no_coverage_data_found: false }.to_not raise_error(RuntimeError)
|
171
206
|
end
|
207
|
+
|
208
|
+
it 'prints default success subtitle' do
|
209
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
210
|
+
|
211
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
212
|
+
@my_plugin.minimum_class_coverage_percentage = 40
|
213
|
+
|
214
|
+
@my_plugin.report path_a
|
215
|
+
|
216
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
217
|
+
expected += "#### All classes meet coverage requirement. Well done! :white_check_mark:\n"
|
218
|
+
expected += "| Class | Covered | Required | Status |\n"
|
219
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
220
|
+
expected += "| `com/example/CachedRepository` | 50% | 40% | :white_check_mark: |\n"
|
221
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'prints default failure subtitle' do
|
225
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
226
|
+
|
227
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
228
|
+
@my_plugin.minimum_class_coverage_percentage = 60
|
229
|
+
|
230
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 60%/)
|
231
|
+
|
232
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
233
|
+
expected += "#### There are classes that do not meet coverage requirement :warning:\n"
|
234
|
+
expected += "| Class | Covered | Required | Status |\n"
|
235
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
236
|
+
expected += "| `com/example/CachedRepository` | 50% | 60% | :warning: |\n"
|
237
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'prints custom success subtitle' do
|
241
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
242
|
+
|
243
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
244
|
+
@my_plugin.minimum_class_coverage_percentage = 40
|
245
|
+
@my_plugin.subtitle_success = 'You rock! 🔥'
|
246
|
+
|
247
|
+
@my_plugin.report path_a
|
248
|
+
|
249
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
250
|
+
expected += "#### You rock! 🔥\n"
|
251
|
+
expected += "| Class | Covered | Required | Status |\n"
|
252
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
253
|
+
expected += "| `com/example/CachedRepository` | 50% | 40% | :white_check_mark: |\n"
|
254
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'prints custom failure subtitle' do
|
258
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
259
|
+
|
260
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
261
|
+
@my_plugin.minimum_class_coverage_percentage = 60
|
262
|
+
@my_plugin.subtitle_failure = 'Too bad :('
|
263
|
+
|
264
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 60%/)
|
265
|
+
|
266
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
267
|
+
expected += "#### Too bad :(\n"
|
268
|
+
expected += "| Class | Covered | Required | Status |\n"
|
269
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
270
|
+
expected += "| `com/example/CachedRepository` | 50% | 60% | :warning: |\n"
|
271
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'prints default class column title' do
|
275
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
276
|
+
|
277
|
+
@my_plugin.report path_a
|
278
|
+
|
279
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'prints custom class column title' do
|
283
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
284
|
+
|
285
|
+
@my_plugin.class_column_title = 'New files'
|
286
|
+
|
287
|
+
@my_plugin.report path_a
|
288
|
+
|
289
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| New files | Covered | Required | Status |')
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'instruction coverage takes over all the rest coverages for classes' do
|
293
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_d.xml"
|
294
|
+
|
295
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
296
|
+
|
297
|
+
@my_plugin.report path_a
|
298
|
+
|
299
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 71% | 50% | :white_check_mark: |')
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'branch coverage takes over line coverage for classes, when instruction coverage is not available' do
|
303
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_e.xml"
|
304
|
+
|
305
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
306
|
+
|
307
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 50%/)
|
308
|
+
|
309
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 42% | 50% | :warning: |')
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'line coverage takes over for classes, when both instruction coverage and branch coverage are not available' do
|
313
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_f.xml"
|
314
|
+
|
315
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
316
|
+
|
317
|
+
@my_plugin.report path_a
|
318
|
+
|
319
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 93% | 50% | :white_check_mark: |')
|
320
|
+
end
|
321
|
+
|
322
|
+
describe 'with CachedRepository containing @Composable annotation' do
|
323
|
+
before do
|
324
|
+
allow(File).to receive(:exist?).with('src/java/com/example/CachedRepository.java').and_return(true)
|
325
|
+
allow(File).to receive(:read).with('src/java/com/example/CachedRepository.java').and_return('package com.kevin.mia.mikaela class Vika { @Composable fun someUiWidget() {} }')
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'applies minimum_composable_class_coverage_percentage' do
|
329
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
330
|
+
|
331
|
+
@my_plugin.minimum_class_coverage_percentage = 55
|
332
|
+
@my_plugin.minimum_composable_class_coverage_percentage = 45
|
333
|
+
|
334
|
+
@my_plugin.report path_a
|
335
|
+
|
336
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 45% | :white_check_mark: |')
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
describe 'with CachedRepository _not_ containing @Composable annotation' do
|
341
|
+
before do
|
342
|
+
allow(File).to receive(:exist?).with('src/java/com/example/CachedRepository.java').and_return(true)
|
343
|
+
allow(File).to receive(:read).with('src/java/com/example/CachedRepository.java').and_return('package com.kevin.mia.mikaela class Vika { fun main() {} }')
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'does not apply minimum_composable_class_coverage_percentage' do
|
347
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
348
|
+
|
349
|
+
@my_plugin.minimum_class_coverage_percentage = 55
|
350
|
+
@my_plugin.minimum_composable_class_coverage_percentage = 45
|
351
|
+
|
352
|
+
expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 55%/)
|
353
|
+
|
354
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 55% | :warning: |')
|
355
|
+
end
|
356
|
+
end
|
172
357
|
end
|
173
358
|
end
|
174
359
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-jacoco-instacart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12.SNAPSHOT.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Malinskiy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-08
|
12
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: danger-plugin-api
|
@@ -179,6 +179,11 @@ files:
|
|
179
179
|
- ".github/workflows/release.yaml"
|
180
180
|
- ".gitignore"
|
181
181
|
- ".rubocop.yml"
|
182
|
+
- ".yardoc/checksums"
|
183
|
+
- ".yardoc/complete"
|
184
|
+
- ".yardoc/object_types"
|
185
|
+
- ".yardoc/objects/root.dat"
|
186
|
+
- ".yardoc/proxy_types"
|
182
187
|
- Gemfile
|
183
188
|
- Guardfile
|
184
189
|
- LICENSE.txt
|
@@ -202,6 +207,10 @@ files:
|
|
202
207
|
- lib/jacoco/sax_parser.rb
|
203
208
|
- spec/fixtures/output_a.xml
|
204
209
|
- spec/fixtures/output_b.xml
|
210
|
+
- spec/fixtures/output_c.xml
|
211
|
+
- spec/fixtures/output_d.xml
|
212
|
+
- spec/fixtures/output_e.xml
|
213
|
+
- spec/fixtures/output_f.xml
|
205
214
|
- spec/jacoco_spec.rb
|
206
215
|
- spec/spec_helper.rb
|
207
216
|
homepage: https://github.com/alexanderbezverhni/danger-jacoco
|
@@ -219,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
228
|
version: '2.6'
|
220
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
230
|
requirements:
|
222
|
-
- - "
|
231
|
+
- - ">"
|
223
232
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
233
|
+
version: 1.3.1
|
225
234
|
requirements: []
|
226
235
|
rubygems_version: 3.1.2
|
227
236
|
signing_key:
|
@@ -230,5 +239,9 @@ summary: A longer description of danger-jacoco.
|
|
230
239
|
test_files:
|
231
240
|
- spec/fixtures/output_a.xml
|
232
241
|
- spec/fixtures/output_b.xml
|
242
|
+
- spec/fixtures/output_c.xml
|
243
|
+
- spec/fixtures/output_d.xml
|
244
|
+
- spec/fixtures/output_e.xml
|
245
|
+
- spec/fixtures/output_f.xml
|
233
246
|
- spec/jacoco_spec.rb
|
234
247
|
- spec/spec_helper.rb
|