nanonano87-cucumber_statistics 0.0.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 +7 -0
- data/.document +5 -0
- data/.gitignore +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +46 -0
- data/README.md +44 -0
- data/Rakefile +7 -0
- data/cucumber_statistics.gemspec +38 -0
- data/lib/cucumber_statistics.rb +8 -0
- data/lib/cucumber_statistics/autoload.rb +5 -0
- data/lib/cucumber_statistics/configuration.rb +56 -0
- data/lib/cucumber_statistics/feature_statistics.rb +28 -0
- data/lib/cucumber_statistics/formatter.rb +101 -0
- data/lib/cucumber_statistics/overall_statistics.rb +29 -0
- data/lib/cucumber_statistics/renderer.rb +30 -0
- data/lib/cucumber_statistics/renderer_helper.rb +102 -0
- data/lib/cucumber_statistics/scenario_statistics.rb +28 -0
- data/lib/cucumber_statistics/step_statistics.rb +91 -0
- data/lib/cucumber_statistics/unused_steps.rb +18 -0
- data/lib/cucumber_statistics/version.rb +3 -0
- data/lib/cucumber_statistics/view/combined_statistics.html +299 -0
- data/lib/cucumber_statistics/view/combined_statistics.html.haml +169 -0
- data/notes.txt +9 -0
- data/spec/cucumber_statistics/configuration_spec.rb +20 -0
- data/spec/cucumber_statistics/feature_statistics_spec.rb +78 -0
- data/spec/cucumber_statistics/renderer_helper_spec.rb +27 -0
- data/spec/cucumber_statistics/renderer_spec.rb +71 -0
- data/spec/cucumber_statistics/scenario_statistics_spec.rb +86 -0
- data/spec/cucumber_statistics/step_statistics_spec.rb +199 -0
- data/spec/cucumber_statistics/unused_steps_spec.rb +39 -0
- data/spec/spec_helper.rb +9 -0
- metadata +184 -0
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CucumberStatistics
|
4
|
+
describe StepStatistics do
|
5
|
+
|
6
|
+
subject(:step_statistics) { StepStatistics.new }
|
7
|
+
subject(:overall_statistics) { OverallStatistics.new }
|
8
|
+
|
9
|
+
describe 'record' do
|
10
|
+
it 'should create a record' do
|
11
|
+
record 'my step', 50
|
12
|
+
|
13
|
+
expect(step_statistics.all.count).to eq 1
|
14
|
+
expect(step_statistics.all['my step'][:instances].count).to eq 1
|
15
|
+
expect(step_statistics.all['my step'][:instances].first).to eq 50
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should support multiple instances of record' do
|
19
|
+
record 'my step', 50
|
20
|
+
record 'my step', 75
|
21
|
+
|
22
|
+
expect(step_statistics.all.count).to eq 1
|
23
|
+
expect(step_statistics.all['my step'][:instances].count).to eq 2
|
24
|
+
expect(step_statistics.all['my step'][:instances].first).to eq 50
|
25
|
+
expect(step_statistics.all['my step'][:instances].last).to eq 75
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'calculate' do
|
30
|
+
before(:each) do
|
31
|
+
record 'my step', 25
|
32
|
+
record 'my step', 50
|
33
|
+
record 'my step', 75
|
34
|
+
|
35
|
+
step_statistics.calculate
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should calculate the total elapsed time' do
|
39
|
+
expect(step_statistics.all['my step'][:total]).to eq 150
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should calculate the number of count' do
|
43
|
+
expect(step_statistics.all['my step'][:count]).to eq 3
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should calculate the average time' do
|
47
|
+
expect(step_statistics.all['my step'][:average]).to eq 50
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should calculate the fastest step' do
|
51
|
+
expect(step_statistics.all['my step'][:fastest]).to eq 25
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should calculate the slowest step' do
|
55
|
+
expect(step_statistics.all['my step'][:slowest]).to eq 75
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should calculate the variation' do
|
59
|
+
expect(step_statistics.all['my step'][:variation]).to eq 50
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should calculate the standard deviation' do
|
63
|
+
expect(step_statistics.all['my step'][:standard_deviation]).to eq 25
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should calculate the variance' do
|
67
|
+
expect(step_statistics.all['my step'][:variance]).to eq 625
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'all' do
|
72
|
+
before(:each) do
|
73
|
+
record 'my step 1', 24
|
74
|
+
record 'my step 1', 50
|
75
|
+
record 'my step 2', 75
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return all records' do
|
79
|
+
expect(step_statistics.all.count).to eq 2
|
80
|
+
step_statistics.all.each_with_index do |step_name, data, index|
|
81
|
+
case index
|
82
|
+
when 1
|
83
|
+
expect(step_name).to eq 'my_step 2'
|
84
|
+
when 2
|
85
|
+
expect(step_name).to eq 'my_step 1'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'set operations' do
|
92
|
+
before(:each) do
|
93
|
+
record 'my step 1', 25
|
94
|
+
record 'my step 1', 50
|
95
|
+
record 'my step 2', 49
|
96
|
+
record 'my step 2', 51
|
97
|
+
record 'my step 3', 75
|
98
|
+
record 'my step 3', 10
|
99
|
+
|
100
|
+
step_statistics.calculate
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'sort_by_property' do
|
104
|
+
it 'should sort all records by any property' do
|
105
|
+
expect(step_statistics.sort_by_property(:total).first.first).to eq 'my step 1'
|
106
|
+
expect(step_statistics.sort_by_property(:total).last.first).to eq 'my step 2'
|
107
|
+
|
108
|
+
expect(step_statistics.sort_by_property(:fastest).first.first).to eq 'my step 3'
|
109
|
+
expect(step_statistics.sort_by_property(:fastest).last.first).to eq 'my step 2'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'highest_average' do
|
114
|
+
it 'should return the record with the highest average' do
|
115
|
+
expect(step_statistics.highest_average.first).to eq 'my step 2'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'highest_elapsed_time' do
|
120
|
+
it 'should return the record with the highest elapsed time' do
|
121
|
+
expect(step_statistics.highest_total.first).to eq 'my step 2'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe 'greatest_variation' do
|
126
|
+
it 'should return the record with the greatest variation between slow and fast' do
|
127
|
+
expect(step_statistics.highest_variation.first).to eq 'my step 3'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'step_part_of_total' do
|
132
|
+
it 'should return the total times of each step from largest to smallest' do
|
133
|
+
expect(step_statistics.step_part_of_total).to eq [100.0, 85.0, 75.0]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'total_elapsed_time' do
|
138
|
+
it 'should return the count of all steps' do
|
139
|
+
expect(step_statistics.total_elapsed_time).to eq 260
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'average_times_plot_data' do
|
144
|
+
it 'should return all the averages sorted by average amount descending' do
|
145
|
+
record 'my step 1', 25
|
146
|
+
record 'my step 1', 50
|
147
|
+
record 'my step 2', 49
|
148
|
+
record 'my step 2', 51
|
149
|
+
record 'my step 3', 75
|
150
|
+
record 'my step 3', 10
|
151
|
+
|
152
|
+
step_statistics.calculate
|
153
|
+
|
154
|
+
expect(step_statistics.average_times_plot_data).to eq [50.0, 42.5, 37.5]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe 'total_times_plot_data' do
|
159
|
+
it 'should return the total times of each step sorted by average amount descending' do
|
160
|
+
record 'my step 1', 25
|
161
|
+
record 'my step 1', 50
|
162
|
+
record 'my step 3', 75
|
163
|
+
record 'my step 3', 10
|
164
|
+
|
165
|
+
step_statistics.calculate
|
166
|
+
|
167
|
+
expect(step_statistics.total_times_plot_data).to eq [100.0, 170, 150.0]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe 'sample_variance' do
|
173
|
+
it 'should calculate the variance' do
|
174
|
+
expect(step_statistics.sample_variance([1, 2, 3, 4, 5, 6])).to be_within(0.1).of(3.5)
|
175
|
+
expect(step_statistics.sample_variance([2, 4, 4, 4, 5, 5, 7, 9])).to be_within(0.1).of(4.57)
|
176
|
+
expect(step_statistics.sample_variance([25, 50, 75])).to be_within(0.1).of(625)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe 'standard_deviation' do
|
181
|
+
it 'should calculate the standard deviation' do
|
182
|
+
sample_variance = step_statistics.sample_variance([1, 2, 3, 4, 5, 6])
|
183
|
+
expect(step_statistics.standard_deviation(sample_variance)).to be_within(0.1).of(1.87)
|
184
|
+
|
185
|
+
sample_variance = step_statistics.sample_variance([2, 4, 4, 4, 5, 5, 7, 9])
|
186
|
+
expect(step_statistics.standard_deviation(sample_variance)).to be_within(0.1).of(2.13)
|
187
|
+
|
188
|
+
sample_variance = step_statistics.sample_variance([25, 50, 75])
|
189
|
+
expect(step_statistics.standard_deviation(sample_variance)).to be_within(0.1).of(25)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def record(step_name, duration)
|
194
|
+
# fake a source for convenience
|
195
|
+
step_statistics.record step_name, duration, '/Users/kross/alienfast/acme/features/account management/admin_cancel_account.feature:8'
|
196
|
+
#overall_statistics.step_count_inc
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CucumberStatistics
|
4
|
+
describe UnusedSteps do
|
5
|
+
subject do
|
6
|
+
UnusedSteps.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'record' do
|
10
|
+
it 'should create a record' do
|
11
|
+
subject.record 'my_step', 'some code somewhere'
|
12
|
+
expect(subject.all['my_step']).to eq 'some code somewhere'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'all' do
|
17
|
+
it 'should return all records sorted alphabetically' do
|
18
|
+
subject.record 'my_step 3', 'some code somewhere 3'
|
19
|
+
subject.record 'my_step 2', 'some code somewhere 2'
|
20
|
+
subject.record 'my_step 1', 'some code somewhere 1'
|
21
|
+
|
22
|
+
expect(subject.all.count).to eq 3
|
23
|
+
subject.all.each_with_index do |step_name, where, index|
|
24
|
+
case index
|
25
|
+
when 1
|
26
|
+
expect(step_name).to eq 'my_step 1'
|
27
|
+
expect(where).to eq 'some code somewhere 1'
|
28
|
+
when 2
|
29
|
+
expect(step_name).to eq 'my_step 2'
|
30
|
+
expect(where).to eq 'some code somewhere 1'
|
31
|
+
when 3
|
32
|
+
expect(step_name).to eq 'my_step 3'
|
33
|
+
expect(where).to eq 'some code somewhere 1'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanonano87-cucumber_statistics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Weimun Ding
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: haml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tilt
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cucumber
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: virtus
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: |2
|
112
|
+
Want to know what is slowing down your build?
|
113
|
+
email:
|
114
|
+
- ding.wm7@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".document"
|
120
|
+
- ".gitignore"
|
121
|
+
- ".ruby-gemset"
|
122
|
+
- ".ruby-version"
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- cucumber_statistics.gemspec
|
128
|
+
- lib/cucumber_statistics.rb
|
129
|
+
- lib/cucumber_statistics/autoload.rb
|
130
|
+
- lib/cucumber_statistics/configuration.rb
|
131
|
+
- lib/cucumber_statistics/feature_statistics.rb
|
132
|
+
- lib/cucumber_statistics/formatter.rb
|
133
|
+
- lib/cucumber_statistics/overall_statistics.rb
|
134
|
+
- lib/cucumber_statistics/renderer.rb
|
135
|
+
- lib/cucumber_statistics/renderer_helper.rb
|
136
|
+
- lib/cucumber_statistics/scenario_statistics.rb
|
137
|
+
- lib/cucumber_statistics/step_statistics.rb
|
138
|
+
- lib/cucumber_statistics/unused_steps.rb
|
139
|
+
- lib/cucumber_statistics/version.rb
|
140
|
+
- lib/cucumber_statistics/view/combined_statistics.html
|
141
|
+
- lib/cucumber_statistics/view/combined_statistics.html.haml
|
142
|
+
- notes.txt
|
143
|
+
- spec/cucumber_statistics/configuration_spec.rb
|
144
|
+
- spec/cucumber_statistics/feature_statistics_spec.rb
|
145
|
+
- spec/cucumber_statistics/renderer_helper_spec.rb
|
146
|
+
- spec/cucumber_statistics/renderer_spec.rb
|
147
|
+
- spec/cucumber_statistics/scenario_statistics_spec.rb
|
148
|
+
- spec/cucumber_statistics/step_statistics_spec.rb
|
149
|
+
- spec/cucumber_statistics/unused_steps_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
homepage: https://github.com/nanonano87/cucumber_statistics
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.4.5.2
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: An cucumber formatter that will gather statistics and generate a single page
|
175
|
+
showing step time metrics.
|
176
|
+
test_files:
|
177
|
+
- spec/cucumber_statistics/configuration_spec.rb
|
178
|
+
- spec/cucumber_statistics/feature_statistics_spec.rb
|
179
|
+
- spec/cucumber_statistics/renderer_helper_spec.rb
|
180
|
+
- spec/cucumber_statistics/renderer_spec.rb
|
181
|
+
- spec/cucumber_statistics/scenario_statistics_spec.rb
|
182
|
+
- spec/cucumber_statistics/step_statistics_spec.rb
|
183
|
+
- spec/cucumber_statistics/unused_steps_spec.rb
|
184
|
+
- spec/spec_helper.rb
|