cuke_parser 0.1.2 → 1.0.0
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.
- data/lib/assets/javascripts/bootstrap.js +2291 -0
- data/lib/assets/javascripts/jquery.js +2 -0
- data/lib/assets/stylesheets/application.css +129 -0
- data/lib/assets/stylesheets/bootstrap.css +6315 -0
- data/lib/cuke_model/suite.rb +1 -1
- data/lib/cuke_parser.rb +21 -14
- data/lib/parse_engine/html_parser.rb +1 -5
- data/lib/parse_engine/json_parser.rb +3 -6
- data/lib/report_engine/feature_page.rb +98 -0
- data/lib/report_engine/home_page.rb +92 -0
- data/lib/report_engine/html_reporter.rb +26 -0
- data/lib/report_engine/reporter_utils.rb +62 -0
- data/test/cuke_parser_test.rb +7 -0
- data/test/json_test.rb +1 -1
- data/test/report_test.rb +88 -0
- data/test/results/json_jenkins_results.txt +1 -1
- data/test/results/json_results.txt +1 -1
- metadata +25 -14
data/lib/cuke_model/suite.rb
CHANGED
|
@@ -21,7 +21,7 @@ module CukeParser
|
|
|
21
21
|
|
|
22
22
|
def to_csv
|
|
23
23
|
#prints pretty csv format
|
|
24
|
-
"#@date
|
|
24
|
+
"#@date,#@time,#@duration,#@converted_duration,#@browser,#@os,#@branch_number,#@branch_build_tag,#@url,#@status"
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def to_csv_pretty
|
data/lib/cuke_parser.rb
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
3
|
-
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'json'
|
|
3
|
+
Dir[File.join(File.dirname(__FILE__),'parse_engine','*.rb')].each {|file| require file}
|
|
4
|
+
Dir[File.join(File.dirname(__FILE__),'report_engine','*.rb')].each {|file| require file}
|
|
4
5
|
|
|
5
6
|
module CukeParser
|
|
6
|
-
|
|
7
|
-
@json_parser = ParseEngine::JsonParser.new
|
|
8
|
-
@html_parser = ParseEngine::HtmlParser.new
|
|
9
|
-
@parser_utils = ParseEngine::ParserUtils.new
|
|
10
7
|
|
|
11
|
-
def CukeParser.write_pretty(
|
|
12
|
-
|
|
8
|
+
def CukeParser.write_pretty(cuke,file)
|
|
9
|
+
parser_utils = ParseEngine::ParserUtils.new
|
|
10
|
+
parser_utils.pretty(cuke,file)
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
def CukeParser.write_build(
|
|
16
|
-
|
|
13
|
+
def CukeParser.write_build(cuke,file)
|
|
14
|
+
parser_utils = ParseEngine::ParserUtils.new
|
|
15
|
+
parser_utils.ugly(cuke,file)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
def CukeParser.json(file_path)
|
|
20
|
-
|
|
19
|
+
json_parser = ParseEngine::JsonParser.new
|
|
20
|
+
json_parser.get_build(file_path)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def CukeParser.json_jenkins_list(file_path,timestamp)
|
|
24
|
-
|
|
24
|
+
json_parser = ParseEngine::JsonParser.new
|
|
25
|
+
json_parser.get_jenkins_build_list(file_path,timestamp)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def CukeParser.html(file_path)
|
|
28
|
-
|
|
29
|
+
html_parser = ParseEngine::HtmlParser.new
|
|
30
|
+
html_parser.get_build(file_path)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def CukeParser.generate_report(cuke,options)
|
|
34
|
+
reporter = ReportEngine::HtmlReporter.new(options[:output_dir],cuke.date.gsub("-","_")+"_"+cuke.time.gsub("-","_"),options[:json_file])
|
|
35
|
+
reporter.generate_report(cuke,options[:title])
|
|
29
36
|
end
|
|
30
37
|
|
|
31
38
|
end #end CukeParser module
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require 'cuke_model/feature.rb'
|
|
3
|
-
require 'cuke_model/scenario.rb'
|
|
4
|
-
require 'cuke_model/step.rb'
|
|
5
|
-
require 'cuke_model/suite.rb'
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__),'..','cuke_model','*.rb')].each {|file| require file}
|
|
6
2
|
|
|
7
3
|
module CukeParser
|
|
8
4
|
module ParseEngine
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
require
|
|
2
|
-
require 'cuke_model/feature.rb'
|
|
3
|
-
require 'cuke_model/scenario.rb'
|
|
4
|
-
require 'cuke_model/step.rb'
|
|
5
|
-
require 'cuke_model/suite.rb'
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__),'..','cuke_model','*.rb')].each {|file| require file}
|
|
6
2
|
|
|
7
3
|
module CukeParser
|
|
8
4
|
module ParseEngine
|
|
@@ -20,6 +16,7 @@ module CukeParser
|
|
|
20
16
|
today = Time.now
|
|
21
17
|
date = today.to_s.split(" ")[0]
|
|
22
18
|
time = today.to_s.split(" ")[1]
|
|
19
|
+
time.gsub!(":","-")
|
|
23
20
|
@cur_build = CukeModel::CukeSuite.new(date,time,today,nil,nil,nil,nil,nil)
|
|
24
21
|
return parse_build(file_path)
|
|
25
22
|
else
|
|
@@ -109,7 +106,7 @@ module CukeParser
|
|
|
109
106
|
cur_path = dir_path + "/" + build_folder
|
|
110
107
|
system_data_file_path = cur_path + @system_data_path
|
|
111
108
|
cuke_file_path = cur_path + @cuke_data
|
|
112
|
-
if Dir.exists?(cur_path) and File.exists?(system_data_file_path) and File.exists?(cuke_file_path) and (File.size(cuke_file_path) >
|
|
109
|
+
if Dir.exists?(cur_path) and File.exists?(system_data_file_path) and File.exists?(cuke_file_path) and (File.size(cuke_file_path) > 1024)
|
|
113
110
|
timestamp = @utils.parse_time(build_folder.split("_"))
|
|
114
111
|
system_data_file = File.read(system_data_file_path)
|
|
115
112
|
system_data = JSON.parse(system_data_file)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module CukeParser
|
|
2
|
+
module ReportEngine
|
|
3
|
+
class FeaturePage
|
|
4
|
+
|
|
5
|
+
def initialize(utils,cuke_metrics)
|
|
6
|
+
@utils = utils
|
|
7
|
+
@cuke_metrics = cuke_metrics
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create_feature_page(feature,output_dir)
|
|
11
|
+
output = File.new(output_dir+"/features/"+feature.name+".html","w+")
|
|
12
|
+
builder = Nokogiri::HTML::Builder.new do |doc|
|
|
13
|
+
doc.html{
|
|
14
|
+
doc.link(:href => "../assets/stylesheets/bootstrap.css", :rel => "stylesheet")
|
|
15
|
+
doc.link(:href => "../assets/stylesheets/application.css", :rel => "stylesheet")
|
|
16
|
+
doc.script(:src => "../assets/javascripts/bootstrap.js", :type => "text/javascript")
|
|
17
|
+
doc.script(:src => "../assets/javascripts/jquery.js", :type => "text/javascript")
|
|
18
|
+
doc.body{
|
|
19
|
+
statistics_table(feature,doc)
|
|
20
|
+
doc.div(:class => "container"){
|
|
21
|
+
doc.div(:class => "row"){
|
|
22
|
+
doc.div(:class => "span12"){
|
|
23
|
+
feature.scenarios.each {|scenario| scenario_info(scenario,doc)}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
output.puts builder.to_html
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def step_error(step,doc)
|
|
34
|
+
doc.div(:class => "rounded error-message") {
|
|
35
|
+
doc.span(step.reason_for_failure)
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def step_info(step,doc)
|
|
40
|
+
doc.span({:class => "keyword-step"},step.keyword.strip + ": ")
|
|
41
|
+
doc.span({:class => "non-keyword-step"},step.name)
|
|
42
|
+
step_error(step,doc) if step.status.eql?("failed")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def scenario_info(scenario,doc)
|
|
46
|
+
doc.div(:class => "rounded "+scenario.status){
|
|
47
|
+
doc.span({:class => "keyword-scenario"},scenario.keyword + ": ")
|
|
48
|
+
doc.span({:class => "non-keyword-scenario"},scenario.name)
|
|
49
|
+
scenario.steps.each {|step| doc.div({:class => "step "+step.status}){step_info(step,doc)}}
|
|
50
|
+
doc.br{}
|
|
51
|
+
}
|
|
52
|
+
doc.br{}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def statistics_table(feature,doc)
|
|
56
|
+
doc.h1({:class => "fancy-header"},feature.name + " Result")
|
|
57
|
+
doc.table(:class => "table table-bordered table-condensed feature-table neutral") {
|
|
58
|
+
doc.thead {
|
|
59
|
+
doc.tr {
|
|
60
|
+
doc.th()
|
|
61
|
+
doc.th({:colspan => 3, :class => "scenarios_header",},"Scenarios")
|
|
62
|
+
doc.th({:colspan => 4, :align => "center"},"Steps")
|
|
63
|
+
doc.th()
|
|
64
|
+
doc.th()
|
|
65
|
+
}
|
|
66
|
+
doc.tr {
|
|
67
|
+
doc.th("Feature")
|
|
68
|
+
doc.th("Total")
|
|
69
|
+
doc.th("Passed")
|
|
70
|
+
doc.th("Failed")
|
|
71
|
+
doc.th("Total")
|
|
72
|
+
doc.th("Passed")
|
|
73
|
+
doc.th("Failed")
|
|
74
|
+
doc.th("Skipped")
|
|
75
|
+
doc.th("Duration")
|
|
76
|
+
doc.th("Status")
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
doc.tr(@utils.model_status_display(feature.status)) {
|
|
80
|
+
doc.td(feature.name)
|
|
81
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:scenario_count])
|
|
82
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:passed])
|
|
83
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:failed])
|
|
84
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:step_count])
|
|
85
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:passed])
|
|
86
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:failed])
|
|
87
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:skipped])
|
|
88
|
+
doc.td(@utils.time_to_words(feature.duration))
|
|
89
|
+
doc.td {
|
|
90
|
+
doc.span(feature.status)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module CukeParser
|
|
2
|
+
module ReportEngine
|
|
3
|
+
class HomePage
|
|
4
|
+
|
|
5
|
+
def initialize(utils,cuke_metrics)
|
|
6
|
+
@utils = utils
|
|
7
|
+
@cuke_metrics = cuke_metrics
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def cuke_statistics_table(cuke,doc)
|
|
11
|
+
doc.table(:class => "table table-bordered table-condensed neutral") {
|
|
12
|
+
doc.thead {
|
|
13
|
+
doc.tr {
|
|
14
|
+
doc.th()
|
|
15
|
+
doc.th({:colspan => 3, :padding => "5px",},"Scenarios")
|
|
16
|
+
doc.th({:colspan => 4, :align => "center"},"Steps")
|
|
17
|
+
doc.th()
|
|
18
|
+
doc.th()
|
|
19
|
+
}
|
|
20
|
+
doc.tr {
|
|
21
|
+
doc.th("Feature")
|
|
22
|
+
doc.th("Total")
|
|
23
|
+
doc.th("Passed")
|
|
24
|
+
doc.th("Failed")
|
|
25
|
+
doc.th("Total")
|
|
26
|
+
doc.th("Passed")
|
|
27
|
+
doc.th("Failed")
|
|
28
|
+
doc.th("Skipped")
|
|
29
|
+
doc.th("Duration")
|
|
30
|
+
doc.th("Status")
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
cuke.features.each do |feature|
|
|
34
|
+
doc.tr(@utils.model_status_display(feature.status)) {
|
|
35
|
+
doc.td{
|
|
36
|
+
doc.a({:href => "features/"+feature.name+".html"},(feature.name))
|
|
37
|
+
}
|
|
38
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:scenario_count])
|
|
39
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:passed])
|
|
40
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:feature_metrics][:failed])
|
|
41
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:step_count])
|
|
42
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:passed])
|
|
43
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:failed])
|
|
44
|
+
doc.td(@cuke_metrics[feature.name.to_sym][:scenario_metrics][:skipped])
|
|
45
|
+
doc.td(@utils.time_to_words(feature.duration))
|
|
46
|
+
doc.td {
|
|
47
|
+
doc.span(feature.status)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
doc.tr {
|
|
52
|
+
doc.td(cuke.features.count)
|
|
53
|
+
doc.td(@cuke_metrics[:scenarios_passed_total] + @cuke_metrics[:scenarios_failed_total])
|
|
54
|
+
doc.td(@cuke_metrics[:scenarios_passed_total])
|
|
55
|
+
doc.td(@cuke_metrics[:scenarios_failed_total])
|
|
56
|
+
doc.td(@cuke_metrics[:steps_passed_total] + @cuke_metrics[:steps_failed_total] + @cuke_metrics[:steps_skipped_total])
|
|
57
|
+
doc.td(@cuke_metrics[:steps_passed_total])
|
|
58
|
+
doc.td(@cuke_metrics[:steps_failed_total])
|
|
59
|
+
doc.td(@cuke_metrics[:steps_skipped_total])
|
|
60
|
+
doc.td(@utils.time_to_words(cuke.duration))
|
|
61
|
+
doc.td("Totals")
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def create_home_page(cuke,output_dir,title)
|
|
67
|
+
output = File.new(output_dir+"/home_page.html","w+")
|
|
68
|
+
builder = Nokogiri::HTML::Builder.new do |doc|
|
|
69
|
+
doc.html{
|
|
70
|
+
doc.link(:href => "assets/stylesheets/bootstrap.css", :rel => "stylesheet")
|
|
71
|
+
doc.link(:href => "assets/stylesheets/application.css", :rel => "stylesheet")
|
|
72
|
+
doc.script(:src => "assets/javascripts/bootstrap.js", :type => "text/javascript")
|
|
73
|
+
doc.script(:src => "assets/javascripts/jquery.js", :type => "text/javascript")
|
|
74
|
+
doc.body{
|
|
75
|
+
doc.h1({:class => "fancy-header"},title + " Statistics")
|
|
76
|
+
doc.div(:class => "container") {
|
|
77
|
+
doc.div(:class => "row") {
|
|
78
|
+
doc.div(:class => "span12") {
|
|
79
|
+
cuke_statistics_table(cuke,doc)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
output.puts builder.to_html
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
module CukeParser
|
|
4
|
+
module ReportEngine
|
|
5
|
+
class HtmlReporter
|
|
6
|
+
|
|
7
|
+
def initialize(output_dir,timestamp,json_file)
|
|
8
|
+
@utils = ReporterUtils.new
|
|
9
|
+
Dir.mkdir(output_dir) if !Dir.exists?(output_dir)
|
|
10
|
+
@output_dir = output_dir+"/"+timestamp
|
|
11
|
+
Dir.mkdir(@output_dir)
|
|
12
|
+
Dir.mkdir(@output_dir+"/features")
|
|
13
|
+
FileUtils.cp_r(Dir[Gem::Specification.find_by_name("cuke_parser").gem_dir + "/lib/assets/"],Dir[@output_dir])
|
|
14
|
+
FileUtils.cp(File.new(json_file),Dir.new(@output_dir))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def generate_report(cuke,title)
|
|
18
|
+
cuke_metrics = @utils.find_cuke_metrics(cuke)
|
|
19
|
+
HomePage.new(@utils,cuke_metrics).create_home_page(cuke,@output_dir,title)
|
|
20
|
+
feature_page = FeaturePage.new(@utils,cuke_metrics)
|
|
21
|
+
cuke.features.each {|feature| feature_page.create_feature_page(feature,@output_dir)}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module CukeParser
|
|
2
|
+
module ReportEngine
|
|
3
|
+
class ReporterUtils
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
#I might eventually use this!
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def time_to_words(duration)
|
|
10
|
+
#need to determine if it has hours or minutes for output string!
|
|
11
|
+
t = Time.at(duration / 1000000000.00).gmtime
|
|
12
|
+
if !t.strftime('%H').eql?("00")
|
|
13
|
+
t.strftime('%H hours and %M mins and %S secs and %L ms')
|
|
14
|
+
elsif !t.strftime('%M').eql?("00")
|
|
15
|
+
t.strftime('%M mins and %S secs and %L ms')
|
|
16
|
+
elsif !t.strftime('%S').eql?("00")
|
|
17
|
+
t.strftime('%S secs and %L ms')
|
|
18
|
+
else
|
|
19
|
+
t.strftime('%L ms')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def model_status_display(status)
|
|
24
|
+
status == "failed" ? {:class => "failed"} : (status == "passed" ? {:class => "passed"} : {:class => "skipped"})
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_scenario_metrics(feature)
|
|
28
|
+
feature_metrics = {:scenario_count => 0, :passed => 0, :failed => 0}
|
|
29
|
+
scenario_metrics = {:step_count => 0, :passed => 0, :failed => 0, :skipped => 0}
|
|
30
|
+
#don't want to count background!
|
|
31
|
+
feature_metrics[:scenario_count] = feature.scenarios.count - 1
|
|
32
|
+
feature.scenarios.each do |scenario|
|
|
33
|
+
scenario.status.eql?("passed") ? (scenario.keyword.eql?("Background") ? (feature_metrics[:passed] += 0) : (feature_metrics[:passed] += 1)) : (scenario.keyword.eql?("Background") ? (feature_metrics[:failed] += 0) : (feature_metrics[:failed] += 1))
|
|
34
|
+
scenario_metrics = get_step_metrics(scenario,scenario_metrics)
|
|
35
|
+
end
|
|
36
|
+
return {:feature_metrics => feature_metrics, :scenario_metrics => scenario_metrics}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_step_metrics(scenario,scenario_metrics)
|
|
40
|
+
scenario_metrics[:step_count] += scenario.steps.count
|
|
41
|
+
scenario.steps.each do |step|
|
|
42
|
+
step.status.eql?("passed") ? (scenario_metrics[:passed] += 1) : (step.status.eql?("failed") ? (scenario_metrics[:failed] += 1) : (scenario_metrics[:skipped] += 1))
|
|
43
|
+
end
|
|
44
|
+
return scenario_metrics
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def find_cuke_metrics(cuke)
|
|
48
|
+
cuke_metrics = {:scenarios_passed_total => 0, :scenarios_failed_total => 0, :steps_passed_total => 0,:steps_failed_total => 0,:steps_skipped_total => 0}
|
|
49
|
+
cuke.features.each do |feature|
|
|
50
|
+
cuke_metrics[feature.name.to_sym] = get_scenario_metrics(feature)
|
|
51
|
+
cuke_metrics[:scenarios_failed_total] += cuke_metrics[feature.name.to_sym][:feature_metrics][:failed]
|
|
52
|
+
cuke_metrics[:scenarios_passed_total] += cuke_metrics[feature.name.to_sym][:feature_metrics][:passed]
|
|
53
|
+
cuke_metrics[:steps_skipped_total] += cuke_metrics[feature.name.to_sym][:scenario_metrics][:skipped]
|
|
54
|
+
cuke_metrics[:steps_failed_total] += cuke_metrics[feature.name.to_sym][:scenario_metrics][:failed]
|
|
55
|
+
cuke_metrics[:steps_passed_total] += cuke_metrics[feature.name.to_sym][:scenario_metrics][:passed]
|
|
56
|
+
end
|
|
57
|
+
return cuke_metrics
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
data/test/cuke_parser_test.rb
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
require_relative 'json_test'
|
|
2
|
+
require_relative 'report_test'
|
|
2
3
|
|
|
3
4
|
module CukeParserTest
|
|
4
5
|
|
|
6
|
+
Dir.chdir("./test")
|
|
7
|
+
|
|
5
8
|
json_tester = JsonTest.new
|
|
6
9
|
json_tester.test_json_jenkins_list
|
|
7
10
|
json_tester.test_json
|
|
8
11
|
|
|
12
|
+
report_tester = ReportTest.new
|
|
13
|
+
report_tester.test_utils
|
|
14
|
+
report_tester.test_reporter
|
|
15
|
+
|
|
9
16
|
end
|
data/test/json_test.rb
CHANGED
data/test/report_test.rb
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'cuke_parser'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'rspec'
|
|
4
|
+
|
|
5
|
+
module CukeParserTest
|
|
6
|
+
|
|
7
|
+
class ReportTest
|
|
8
|
+
|
|
9
|
+
include RSpec::Matchers
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@utils = CukeParser::ReportEngine::ReporterUtils.new
|
|
13
|
+
location = "./builds/2013-04-23_03-01-25/archive"
|
|
14
|
+
@cuke = CukeParser.json(location)
|
|
15
|
+
#we need to overwrite the date because get_json_build just grabs Time.now as the date
|
|
16
|
+
@cuke.date = "2013-04-23"
|
|
17
|
+
@cuke.time = "03-01-25"
|
|
18
|
+
@options = {:title => "Rick Suite",:output_dir => "Rick Suite",:json_file => "./builds/2013-04-23_03-01-25/archive/cucumber.json"}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_utils
|
|
22
|
+
test_model_status_display
|
|
23
|
+
test_time_to_words
|
|
24
|
+
test_find_cuke_metrics
|
|
25
|
+
test_get_scenario_metrics
|
|
26
|
+
test_get_step_metrics
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_reporter
|
|
30
|
+
test_generate_report
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_generate_report
|
|
34
|
+
#delete any existing directory to be safe
|
|
35
|
+
FileUtils.rm_rf(Dir[@options[:output_dir]]) if Dir.exists?(@options[:output_dir])
|
|
36
|
+
CukeParser.generate_report(@cuke,@options)
|
|
37
|
+
#don't want to check to make sure files are the same as they are html files and are likely to change often as I update CSS/JS, etc.
|
|
38
|
+
File.exists?("Rick Suite/2013_04_23_03_01_25/cucumber.json").should be_true
|
|
39
|
+
File.exists?("Rick Suite/2013_04_23_03_01_25/home_page.html").should be_true
|
|
40
|
+
File.exists?("Rick Suite/2013_04_23_03_01_25/features/Rick Test.html ").should be_true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_model_status_display
|
|
44
|
+
{:class => "skipped"}.eql?(@utils.model_status_display("skipped")).should be_true
|
|
45
|
+
{:class => "failed"}.eql?(@utils.model_status_display("failed")).should be_true
|
|
46
|
+
{:class => "passed"}.eql?(@utils.model_status_display("passed")).should be_true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_time_to_words
|
|
50
|
+
"01 hours and 23 mins and 20 secs and 000 ms".eql?(@utils.time_to_words(5000000000000)).should be_true
|
|
51
|
+
"16 mins and 40 secs and 000 ms".eql?(@utils.time_to_words(1000000000000)).should be_true
|
|
52
|
+
"50 secs and 000 ms".eql?(@utils.time_to_words(50000000000)).should be_true
|
|
53
|
+
"211 ms".eql?(@utils.time_to_words(211021000)).should be_true
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_get_scenario_metrics
|
|
57
|
+
scenario_metrics = {:feature_metrics=>{:scenario_count=>1, :passed=>1, :failed=>0}, :scenario_metrics=>{:step_count=>7, :passed=>7, :failed=>0, :skipped=>0}}
|
|
58
|
+
scenario_metrics.eql?(@utils.get_scenario_metrics(@cuke.features.first)).should be_true
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_get_step_metrics
|
|
62
|
+
step_metrics = {:step_count=>7, :passed=>7, :failed=>0, :skipped=>0}
|
|
63
|
+
step_metrics.eql?(@utils.get_scenario_metrics(@cuke.features.first)[:scenario_metrics]).should be_true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_find_cuke_metrics
|
|
67
|
+
cuke_metrics = {:scenarios_passed_total=>1, :scenarios_failed_total=>0, :steps_passed_total=>7, :steps_failed_total=>0, :steps_skipped_total=>0,
|
|
68
|
+
:"Rick Test"=>{:feature_metrics=>{:scenario_count=>1, :passed=>1, :failed=>0}, :scenario_metrics=>{:step_count=>7, :passed=>7, :failed=>0, :skipped=>0}}}
|
|
69
|
+
cuke_metrics.eql?(@utils.find_cuke_metrics(@cuke)).should be_true
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_json
|
|
75
|
+
location = "./builds/2013-04-23_03-01-25/archive"
|
|
76
|
+
result = CukeParser.json(location)
|
|
77
|
+
#we need to overwrite the date because get_json_build just grabs Time.now as the date
|
|
78
|
+
result.date = "2013-04-23"
|
|
79
|
+
result.time = "03-01-25"
|
|
80
|
+
#write our results to a text file
|
|
81
|
+
output = File.open("result.txt","w+")
|
|
82
|
+
CukeParser.write_build(result,output)
|
|
83
|
+
output.close
|
|
84
|
+
FileUtils.compare_file("result.txt","./results/json_results.txt").should be_true
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
2013-04-23
|
|
1
|
+
2013-04-23,03-01-25,21000000,00:00:00:021,firefox,Windows_NT,0.0.5,cuke_parser-0.0.5,https://rubygems.org/gems/cuke_parser,passed
|
|
2
2
|
Feature,Rick Test,21000000,00:00:00:021
|
|
3
3
|
Background,,2000000,00:00:00:002
|
|
4
4
|
Given ,numbers "46" and "2",2000000,00:00:00:002,passed
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cuke_parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: builder
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &27450312 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 2.1.2
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *27450312
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: json
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &27450024 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 1.4.6
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *27450024
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: nokogiri
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &27449748 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 1.5.9
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *27449748
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: rake
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &27449472 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 0.9.2
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *27449472
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: rspec
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &27449196 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ~>
|
|
@@ -65,8 +65,9 @@ dependencies:
|
|
|
65
65
|
version: 2.11.0
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
69
|
-
description: Library to easily
|
|
68
|
+
version_requirements: *27449196
|
|
69
|
+
description: Library to easily extract information for tracking your Cukes, their
|
|
70
|
+
overall performance, and generates HTML reports.
|
|
70
71
|
email: rick.beyer@gmail.com
|
|
71
72
|
executables: []
|
|
72
73
|
extensions: []
|
|
@@ -80,8 +81,17 @@ files:
|
|
|
80
81
|
- lib/parse_engine/html_parser.rb
|
|
81
82
|
- lib/parse_engine/json_parser.rb
|
|
82
83
|
- lib/parse_engine/parser_utils.rb
|
|
84
|
+
- lib/report_engine/feature_page.rb
|
|
85
|
+
- lib/report_engine/home_page.rb
|
|
86
|
+
- lib/report_engine/html_reporter.rb
|
|
87
|
+
- lib/report_engine/reporter_utils.rb
|
|
88
|
+
- lib/assets/javascripts/bootstrap.js
|
|
89
|
+
- lib/assets/javascripts/jquery.js
|
|
90
|
+
- lib/assets/stylesheets/application.css
|
|
91
|
+
- lib/assets/stylesheets/bootstrap.css
|
|
83
92
|
- test/cuke_parser_test.rb
|
|
84
93
|
- test/json_test.rb
|
|
94
|
+
- test/report_test.rb
|
|
85
95
|
- test/builds/2013-04-22_03-01-25/archive/cucumber.json
|
|
86
96
|
- test/builds/2013-04-22_03-01-25/archive/systemData.json
|
|
87
97
|
- test/builds/2013-04-23_03-01-25/archive/cucumber.json
|
|
@@ -112,10 +122,11 @@ rubyforge_project:
|
|
|
112
122
|
rubygems_version: 1.8.16
|
|
113
123
|
signing_key:
|
|
114
124
|
specification_version: 3
|
|
115
|
-
summary: cuke_parser-0.
|
|
125
|
+
summary: cuke_parser-1.0.0
|
|
116
126
|
test_files:
|
|
117
127
|
- test/cuke_parser_test.rb
|
|
118
128
|
- test/json_test.rb
|
|
129
|
+
- test/report_test.rb
|
|
119
130
|
- test/builds/2013-04-22_03-01-25/archive/cucumber.json
|
|
120
131
|
- test/builds/2013-04-22_03-01-25/archive/systemData.json
|
|
121
132
|
- test/builds/2013-04-23_03-01-25/archive/cucumber.json
|