Skip to content

Commit 49fdbac

Browse files
committed
scenarios reporter
1 parent a76b928 commit 49fdbac

File tree

4 files changed

+671
-1
lines changed

4 files changed

+671
-1
lines changed

lib/kraken-mobile/helpers/reporter.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'kraken-mobile/constants'
2+
require 'digest'
23

34
module KrakenMobile
45
class Reporter
@@ -38,6 +39,28 @@ def generate_device_report device
3839
File.open(html_file, 'w+') do |f|
3940
f.write result
4041
end
42+
generate_features_report @features, device
43+
end
44+
45+
def generate_features_report features, device
46+
features.each do |feature|
47+
generate_feature_report feature, device
48+
end
49+
end
50+
51+
def generate_feature_report feature, device
52+
Dir.mkdir("#{KrakenMobile::Constants::REPORT_PATH}/#{@execution_id}/#{device.id}/features_report") unless File.exists?("#{KrakenMobile::Constants::REPORT_PATH}/#{@execution_id}/#{device.id}/features_report")
53+
file_name = feature_id feature
54+
erb_file = File.join(File.expand_path("../../../../reporter/", __FILE__), "scenario_report.html.erb")
55+
html_file = File.join(File.expand_path("#{KrakenMobile::Constants::REPORT_PATH}/#{@execution_id}/#{device.id}/features_report"), "#{file_name}.html") #=>"page.html"
56+
# Variables
57+
@feature = feature
58+
template = File.read(erb_file)
59+
result = ERB.new(template).result(binding)
60+
# write result to file
61+
File.open(html_file, 'w+') do |f|
62+
f.write result
63+
end
4164
end
4265

4366
#-------------------------------
@@ -52,6 +75,10 @@ def total_scenarios features
5275
how_many
5376
end
5477

78+
def feature_id feature
79+
Digest::SHA256.hexdigest("#{feature["id"].strip}#{feature["uri"].strip}")
80+
end
81+
5582
def passed_features features
5683
features.select{ |feature| passed_scenarios(feature) == feature["elements"].count }
5784
end
@@ -125,6 +152,14 @@ def total_failed_features features
125152
how_many
126153
end
127154

155+
def feature_passed_scenarios_percentage feature
156+
(passed_scenarios(feature).count.to_f/feature["elements"].count.to_f).round(2) * 100.00
157+
end
158+
159+
def feature_failed_scenarios_percentage feature
160+
(failed_scenarios(feature).count.to_f/feature["elements"].count.to_f).round(2) * 100.00
161+
end
162+
128163
def total_passed_scenarios_percentage features
129164
(total_passed_scenarios(features).to_f/total_scenarios(features).to_f).round(2) * 100.00
130165
end

0 commit comments

Comments
 (0)