Class: CUKES::PerformanceReport
- Inherits:
-
Object
- Object
- CUKES::PerformanceReport
- Defined in:
- lib/friendly/cukes/framework/library/generic/performance_report.rb
Instance Method Summary collapse
-
#convert_duration(num_duration) ⇒ Object
Description : converts nanoseconds to seconds Author : Chandra sekaran Arguments : num_duration : time in nanoseconds Return Argument : time in seconds.
-
#create_performance_report ⇒ Object
Description : function that creates performance report data and stores it in Sybase Author : Chandra sekaran.
-
#get_host_data ⇒ Object
Description : gets the host data from Sybase based on current execution host Author : Chandra sekaran Return Arguments : num_host_id : primary key the host.
-
#initialize(arr_file_path) ⇒ PerformanceReport
constructor
Description : invoked automatically when an object of the class type is created Author : Chandra sekaran Arguments : arr_file_paths : array of html report file paths.
-
#parse_json ⇒ Object
Description : parses the json object saves the required execution data into Sybase DB Author : Chandra sekaran.
-
#reset_build(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) ⇒ Object
Description : resets the build data with execution details into Sybase Author : Chandra sekaran Arguments : num_run_length : total execution time in nanoseconds num_pass_count : number of features passed num_fail_count : number of features failed num_skip_count : number of features skipped bool_result : boolean value resembling the state of build result.
-
#reset_feature_result(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result, num_feature_result_id) ⇒ Object
Description : resets the feature result data with execution details into Sybase Author : Chandra sekaran Arguments : num_run_length : feature execution time in nanoseconds num_pass_count : number of scenarios passed num_fail_count : number of scenarios failed num_skip_count : number of scenarios skipped bool_result : boolean value resembling the state of build result num_feature_result_id : primary key of the TestFeatureResult table.
-
#reset_scenario_result(num_scenario_result_id, num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) ⇒ Object
Description : resets the scenario result data with execution details into Sybase Author : Chandra sekaran Arguments : num_scenario_result_id : primary key of the scenario result num_run_length : steps execution time in nanoseconds num_pass_count : number of steps passed num_fail_count : number of steps failed num_skip_count : number of steps skipped bool_result : boolean value resembling the state of steps result.
-
#reset_step_result(bool_result, num_run_length, num_step_result_id) ⇒ Object
Description : resets the step result data with execution details into Sybase Author : Chandra sekaran Arguments : bool_result : boolean value resembling the state of step result num_run_length : step execution time in nanoseconds num_step_result_id : primary key of step result.
-
#set_build ⇒ Object
Description : sets the build data with default details into Sybase Author : Chandra sekaran.
-
#set_feature(str_feature_name) ⇒ Object
Description : sets the feature data with default details into Sybase Author : Chandra sekaran Arguments : str_feature_name : feature name Return Arguments : num_feature_id : primary key the feature num_feature_result_id : primary key of the feature result.
-
#set_feature_result(num_feature_id) ⇒ Object
Description : sets the feature result data with default details into Sybase Author : Chandra sekaran Arguments : str_feature_name : feature_id of the feature Return Arguments : num_feature_result_id : primary key of the feature result.
-
#set_scenario(str_scenario_name, str_qa_complete_id, str_feature_id) ⇒ Object
Description : sets the scenario data with default details into Sybase Author : Chandra sekaran Arguments : str_scenario_name : scenario name str_qa_complete_id : QA Complete ID (Scenario ID) of the scenario str_feature_id : primary key of the feature Return Arguments : num_scenario_id : primary key of the scenario scenario_result_id : primary key of the scenario result.
-
#set_scenario_result(num_scenario_id, num_feature_id) ⇒ Object
Description : sets the scenario result data with default details into Sybase Author : Chandra sekaran Arguments : num_scenario_id : primary key of the scenario num_feature_id : primary key of the feature Return Arguments : num_scenario_result_id : primary key of the scenario result.
-
#set_step(str_step_name, str_scenario_id, num_scenario_result_id) ⇒ Object
Description : sets the step data with default details into Sybase Author : Chandra sekaran Arguments : str_step_name : step name str_scenario_id : primary key of scenario num_scenario_result_id : primary key of scenario result Return Arguments : num_step_id : primary key of step num_step_result_id : primary key of step result.
-
#set_step_result(num_step_id, num_scenario_id, num_scenario_result_id) ⇒ Object
Description : sets the step result data with default details into Sybase Author : Chandra sekaran Arguments : num_step_id : primary key of step str_scenario_id : primary key of scenario num_scenario_result_id : primary key of scenario result Return Arguments : num_step_result_id : primary key of step result.
-
#set_step_result_new(num_step_id, num_scenario_id, num_scenario_result_id, bool_result, num_run_length) ⇒ Object
Description : sets the step result data with execution details into Sybase Author : Chandra sekaran Arguments : num_step_id : primary key of step num_scenario_id : primary key of scenario num_scenario_result_id : primary key of scenario result bool_result : boolean value resembling the state of step result num_run_length : steps execution time in nanoseconds.
Constructor Details
#initialize(arr_file_path) ⇒ PerformanceReport
Description : invoked automatically when an object of the class type is created Author : Chandra sekaran Arguments :
arr_file_paths : array of html report file paths
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 17 def initialize(arr_file_path) @arr_file_name = arr_file_path @num_build_duration = 0 @bool_build_passed = true @num_feature_count = 0 @num_feature_pass_count = 0 @num_feature_fail_count = 0 @num_feature_skip_count = 0 @str_connection_url = "DBI:SQLAnywhere:SERVER=#{DB_SERVER};DBN=#{DB_NAME}" end |
Instance Method Details
#convert_duration(num_duration) ⇒ Object
Description : converts nanoseconds to seconds Author : Chandra sekaran Arguments :
num_duration : time in nanoseconds
Return Argument : time in seconds
495 496 497 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 495 def convert_duration(num_duration) num_duration/(1000*1000*1000) #.to_f # convert nanosecond to second end |
#create_performance_report ⇒ Object
Description : function that creates performance report data and stores it in Sybase Author : Chandra sekaran
502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 502 def create_performance_report set_build # set Build data only once for each execution (Single or Parallel) @arr_file_name.each do |path| @arr_background_step_duration = [] file = File.read(path) @json = JSON.parse(file) parse_json # parse each json file and extract report data end #puts "Build duration : #{@num_build_duration} - #{@bool_build_passed} - #{@num_feature_count}" reset_build(@num_build_duration, @num_feature_pass_count, @num_feature_fail_count, @num_feature_skip_count, @bool_build_passed) # Update the Build data with execution summary rescue Exception => ex $log.error("Error while creating report : #{ex}") exit end |
#get_host_data ⇒ Object
Description : gets the host data from Sybase based on current execution host Author : Chandra sekaran Return Arguments :
num_host_id : primary key the host
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 156 def get_host_data DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "select HostDataID from HostData where HostName like '#{ENV['COMPUTERNAME'].downcase}' and OS like '#{ENV['OS'].downcase}' and Browser like '#{BROWSER.downcase}'" sth = dbh.prepare(str_query) sth.execute() num_host_id = sth.fetch[0] dbh.disconnect() $log.info("------------host id : #{num_host_id.nil?}") num_host_id.nil? ? 5 : num_host_id end rescue Exception => ex $log.error("Error in getting host data from HostData table: #{ex}") exit end |
#parse_json ⇒ Object
Description : parses the json object saves the required execution data into Sybase DB Author : Chandra sekaran
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 31 def parse_json @json.each_with_index do |json, index| # iterate each feature str_feature_id, num_feature_result_id = set_feature(json["name"].to_s) # add feature name @num_feature_count += 1 scenario_count = 0 feature_duration = 0 bool_feature_passed = true num_scenario_pass_count = 0 num_scenario_fail_count = 0 num_scenario_skip_count = 0 json["elements"].each do |element| # for including the first background steps duration to the first scenario background steps as Cucumber json # report considers background for the first scenario and hence will have 0 duration for the background steps # under first scenario and the actual duration for the background will be set for the subsequent scenarios if index == 0 if element["keyword"] == "Background" element["steps"].each do |step| @arr_background_step_duration << step["result"]["duration"].to_i @bool = true end end end num_step_pass_count = 0 num_step_fail_count = 0 num_step_skip_count = 0 if element["keyword"] == "Scenario" # take scenario for scenario level details str_scenario_id, scenario_result_id = set_scenario(element["name"], element["tags"][0]["name"], str_feature_id) # add scenario name scenario_count += 1 # as it counts only 'Scenarios' and not 'Backgrounds' step_count = 0 scenario_duration = 0 bool_scenario_passed = true element["steps"].each_with_index do |step, indx| # iterate each steps of the current scenario #num_step_id, num_step_result_id = set_step(step['keyword']+step['name'], str_scenario_id, scenario_result_id) # add step name num_step_id = set_step(step['keyword']+step['name'], str_scenario_id, scenario_result_id) # add step name step_count += 1 step_duration = 0 bool_step_passed = true if (index == 0) && (indx < @arr_background_step_duration.size) && @bool step_duration = @arr_background_step_duration[indx] # take duration from Background for the first scenario else step_duration = step['result']['duration'].to_i # take usual duration @bool = false end scenario_duration += step_duration if step['result']['status'] == "passed" num_step_pass_count += 1 elsif step['result']['status'] == "failed" num_step_fail_count += 1 elsif step['result']['status'] == "skipped" num_step_skip_count += 1 end bool_step_passed = ["passed", "pending"].include?(step['result']['status']) ? true : false bool_scenario_passed &&= bool_step_passed #puts "\t\t Step : #{step['keyword']+step['name']} - #{step_duration} - #{bool_step_passed}" #reset_step_result(bool_step_passed, step_duration, num_step_result_id) set_step_result_new(num_step_id, str_scenario_id, scenario_result_id, bool_step_passed, step_duration) end #puts "Scenario : #{element["tags"][0]["name"]} - #{element['name']} - #{scenario_duration} - #{bool_scenario_passed} - #{step_count}" reset_scenario_result(scenario_result_id, scenario_duration, num_step_pass_count, num_step_fail_count, num_step_skip_count, bool_scenario_passed) feature_duration += scenario_duration bool_feature_passed &&= bool_scenario_passed if bool_scenario_passed num_scenario_pass_count += 1 # scenario pass count else if num_step_pass_count == 0 && num_step_fail_count == 0 && num_step_skip_count > 0 num_scenario_skip_count += 1 # scenario skip count else num_scenario_fail_count += 1 # scenario fail count end end end end #puts "Feature : #{json['name']} - #{feature_duration} - #{bool_feature_passed} - #{scenario_count}" reset_feature_result(feature_duration, num_scenario_pass_count, num_scenario_fail_count, num_scenario_skip_count, bool_feature_passed, num_feature_result_id) @num_build_duration += feature_duration @bool_build_passed &&= bool_feature_passed if bool_feature_passed @num_feature_pass_count += 1 else @num_feature_fail_count += 1 # to do feature skip count end end rescue Exception => ex $log.error("Error while parsing JSON : #{ex}") exit end |
#reset_build(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) ⇒ Object
Description : resets the build data with execution details into Sybase Author : Chandra sekaran Arguments :
num_run_length : total execution time in nanoseconds
num_pass_count : number of features passed
num_fail_count : number of features failed
num_skip_count : number of features skipped
bool_result : boolean value resembling the state of build result
180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 180 def reset_build(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) num_result = bool_result ? 1 : 0 DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("update BuildData set RunLength=?, Passes=?, Failures=?, Skips=?, Result=? where BuildID=?") sth.execute(convert_duration(num_run_length), num_pass_count, num_fail_count, num_skip_count, num_result, @build_id) sth.finish dbh.commit #puts "Updated a record (#{@build_id}) in BuildData table successfully" dbh.disconnect() end rescue Exception => ex $log.error("Error in resetting build data to BuildData table: #{ex}") exit end |
#reset_feature_result(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result, num_feature_result_id) ⇒ Object
Description : resets the feature result data with execution details into Sybase Author : Chandra sekaran Arguments :
num_run_length : feature execution time in nanoseconds
num_pass_count : number of scenarios passed
num_fail_count : number of scenarios failed
num_skip_count : number of scenarios skipped
bool_result : boolean value resembling the state of build result
num_feature_result_id : primary key of the TestFeatureResult table
272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 272 def reset_feature_result(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result, num_feature_result_id) num_result = bool_result ? 1 : 0 DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("update TestFeatureResult set RunLength=?, Passes=?, Failures=?, Skips=?, Result=? where TestFeatureResultID=?") sth.execute(convert_duration(num_run_length), num_pass_count, num_fail_count, num_skip_count, num_result, num_feature_result_id) sth.finish dbh.commit #puts "Updated a record (#{num_feature_result_id}) in TestFeatureResult table successfully" dbh.disconnect() end rescue Exception => ex $log.error("Error in resetting feature result data to TestFeatureResult table : #{ex}") exit end |
#reset_scenario_result(num_scenario_result_id, num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) ⇒ Object
Description : resets the scenario result data with execution details into Sybase Author : Chandra sekaran Arguments :
num_scenario_result_id : primary key of the scenario result
num_run_length : steps execution time in nanoseconds
num_pass_count : number of steps passed
num_fail_count : number of steps failed
num_skip_count : number of steps skipped
bool_result : boolean value resembling the state of steps result
364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 364 def reset_scenario_result(num_scenario_result_id, num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) num_result = bool_result ? 1 : 0 DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("update TestScenarioResult set RunLength=?, Passes=?, Failures=?, Skips=?, Result=? where TestScenarioResultID=?") sth.execute(convert_duration(num_run_length), num_pass_count, num_fail_count, num_skip_count, num_result, num_scenario_result_id) sth.finish dbh.commit #puts "Updated a record (#{num_scenario_result_id}) in TestScenarioResult table successfully" dbh.disconnect() end rescue Exception => ex $log.error("Error in resetting scenario data to TestScenarioResult table : #{ex}") exit end |
#reset_step_result(bool_result, num_run_length, num_step_result_id) ⇒ Object
Description : resets the step result data with execution details into Sybase Author : Chandra sekaran Arguments :
bool_result : boolean value resembling the state of step result
num_run_length : step execution time in nanoseconds
num_step_result_id : primary key of step result
474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 474 def reset_step_result(bool_result, num_run_length, num_step_result_id) num_result = bool_result ? 1 : 0 DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("update TestStepResult set Result=?, RunLength=? where TestStepResultID=?") sth.execute(num_result, convert_duration(num_run_length), num_step_result_id) sth.finish dbh.commit #puts "Updated a record (#{num_step_result_id}) in TestStepResult table successfully" dbh.disconnect() end rescue Exception => ex $log.error("Error in resetting step results data in TestStepResult table : #{ex}") exit end |
#set_build ⇒ Object
Description : sets the build data with default details into Sybase Author : Chandra sekaran
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 129 def set_build num_host_id = get_host_data build_name = Time.now.strftime("%d_%m_%Y-%H_%M_%S") DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "insert into BuildData(BuildName,HostDataID) values (?,?)" sth = dbh.prepare(str_query) sth.execute(build_name, num_host_id) sth.finish dbh.commit #puts "Added a record to BuildData table successfully" str_query = "select BuildID from BuildData where BuildName='#{build_name}' and HostDataID=#{num_host_id}" sth = dbh.prepare(str_query) sth.execute() @build_id = sth.fetch[0] dbh.disconnect() end rescue Exception => ex $log.error("Error in setting build data to BuildData table: #{ex}") exit end |
#set_feature(str_feature_name) ⇒ Object
Description : sets the feature data with default details into Sybase Author : Chandra sekaran Arguments :
str_feature_name : feature name
Return Arguments :
num_feature_id : primary key the feature
num_feature_result_id : primary key of the feature result
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 203 def set_feature(str_feature_name) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "select TestFeatureID from TestFeature where FeatureName=?" sth = dbh.prepare(str_query) sth.execute(str_feature_name) if sth.fetch.nil? # insert only if the data is not present in the table sth = dbh.prepare("insert into TestFeature(FeatureName) values (?)") sth.execute(str_feature_name) dbh.commit #puts "Added a record to TestFeature table successfully" end str_query = "select TestFeatureID from TestFeature where FeatureName='#{str_feature_name}'" sth = dbh.prepare(str_query) sth.execute() num_feature_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_feature_id}' in TestFeature *************" dbh.disconnect() num_feature_result_id = set_feature_result(num_feature_id) return num_feature_id, num_feature_result_id # return the feature id and feature result id of the feature end rescue Exception => ex $log.error("Error in setting feature data to TestFeature table : #{ex}") exit end |
#set_feature_result(num_feature_id) ⇒ Object
Description : sets the feature result data with default details into Sybase Author : Chandra sekaran Arguments :
str_feature_name : feature_id of the feature
Return Arguments :
num_feature_result_id : primary key of the feature result
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 236 def set_feature_result(num_feature_id) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "select TestFeatureResultID from TestFeatureResult where TestFeatureID=? and BuildID=?" sth = dbh.prepare(str_query) sth.execute(num_feature_id, @build_id) if sth.fetch.nil? # insert only if the data is not present in the table sth = dbh.prepare("insert into TestFeatureResult(TestFeatureID,BuildID) values (?,?)") sth.execute(num_feature_id, @build_id) dbh.commit #puts "Added a record to TestFeatureResult table successfully" end str_query = "select TestFeatureResultID from TestFeatureResult where TestFeatureID=#{num_feature_id} and BuildID=#{@build_id}" sth = dbh.prepare(str_query) sth.execute() num_feature_result_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_feature_result_id}' in TestFeatureResult *************" dbh.disconnect() return num_feature_result_id # return the feature result id of the feature end rescue Exception => ex $log.error("Error in setting feature result data to TestFeatureResult table : #{ex}") exit end |
#set_scenario(str_scenario_name, str_qa_complete_id, str_feature_id) ⇒ Object
Description : sets the scenario data with default details into Sybase Author : Chandra sekaran Arguments :
str_scenario_name : scenario name
str_qa_complete_id : QA Complete ID (Scenario ID) of the scenario
str_feature_id : primary key of the feature
Return Arguments :
num_scenario_id : primary key of the scenario
scenario_result_id : primary key of the scenario result
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 297 def set_scenario(str_scenario_name, str_qa_complete_id, str_feature_id) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "select TestScenarioID from TestScenario where ScenarioName=? and TestFeatureID=?" sth = dbh.prepare(str_query) sth.execute(str_scenario_name, str_feature_id.to_i) if sth.fetch.nil? # insert only if the data is not present in the table sth = dbh.prepare("insert into TestScenario(ScenarioName,QACompleteID,TestFeatureID) values (?,?,?)") sth.execute(str_scenario_name, str_qa_complete_id, str_feature_id.to_i) sth.finish dbh.commit #puts "Added a record to TestScenario table successfully" end str_query = "select TestScenarioID from TestScenario where ScenarioName='#{str_scenario_name}' and TestFeatureID=#{str_feature_id}" sth = dbh.prepare(str_query) sth.execute() num_scenario_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_scenario_id}' in TestScenario *************" scenario_result_id = set_scenario_result(num_scenario_id, str_feature_id) dbh.disconnect() return num_scenario_id, scenario_result_id # return the scenario id and scenario result id of the scenario end rescue Exception => ex $log.error("Error in setting scenario data to TestScenario table : #{ex}") exit end |
#set_scenario_result(num_scenario_id, num_feature_id) ⇒ Object
Description : sets the scenario result data with default details into Sybase Author : Chandra sekaran Arguments :
num_scenario_id : primary key of the scenario
num_feature_id : primary key of the feature
Return Arguments :
num_scenario_result_id : primary key of the scenario result
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 333 def set_scenario_result(num_scenario_id, num_feature_id) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("insert into TestScenarioResult(TestFeatureID,TestScenarioID,BuildID) values (?,?,?)") sth.execute(num_feature_id, num_scenario_id, @build_id) sth.finish dbh.commit #puts "Added a record to TestScenarioResult table successfully" str_query = "select TestScenarioResultID from TestScenarioResult where TestFeatureID=#{num_feature_id} and TestScenarioID=#{num_scenario_id} and BuildID=#{@build_id}" sth = dbh.prepare(str_query) sth.execute() num_scenario_result_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_scenario_result_id}' in TestScenarioResult *************" dbh.disconnect() return num_scenario_result_id # return the scenario id of the scenario end rescue Exception => ex $log.error("Error in setting scenario data to TestScenarioResult table : #{ex}") exit end |
#set_step(str_step_name, str_scenario_id, num_scenario_result_id) ⇒ Object
Description : sets the step data with default details into Sybase Author : Chandra sekaran Arguments :
str_step_name : step name
str_scenario_id : primary key of scenario
num_scenario_result_id : primary key of scenario result
Return Arguments :
num_step_id : primary key of step
num_step_result_id : primary key of step result
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 389 def set_step(str_step_name, str_scenario_id, num_scenario_result_id) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| str_query = "select TestStepID from TestStep where StepName=? and TestScenarioID=?" sth = dbh.prepare(str_query) sth.execute(str_step_name, str_scenario_id) if sth.fetch.nil? # insert only if the data is not present in the table sth = dbh.prepare("insert into TestStep(StepName,TestScenarioID) values (?,?)") sth.execute(str_step_name, str_scenario_id) dbh.commit #puts "Added a record to TestStep table successfully" end str_query = "select TestStepID from TestStep where StepName='#{str_step_name}' and TestScenarioID=#{str_scenario_id}" sth = dbh.prepare(str_query) sth.execute() num_step_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_step_id}' in TestStep *************" dbh.disconnect() return num_step_id end rescue Exception => ex $log.error("Error in setting step data to TestStep table : #{ex}") exit end |
#set_step_result(num_step_id, num_scenario_id, num_scenario_result_id) ⇒ Object
Description : sets the step result data with default details into Sybase Author : Chandra sekaran Arguments :
num_step_id : primary key of step
str_scenario_id : primary key of scenario
num_scenario_result_id : primary key of scenario result
Return Arguments :
num_step_result_id : primary key of step result
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 447 def set_step_result(num_step_id, num_scenario_id, num_scenario_result_id) DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("insert into TestStepResult(TestScenarioResultID,TestStepID,BuildID,TestScenarioID) values (?,?,?,?)") sth.execute(num_scenario_result_id, num_step_id, @build_id, num_scenario_id) dbh.commit #puts "Added a record to TestStepResult table successfully" str_query = "select TestStepResultID from TestStepResult where TestScenarioResultID=#{num_scenario_result_id} and TestStepID=#{num_step_id} and BuildID=#{@build_id} and TestScenarioID=#{num_scenario_id}" sth = dbh.prepare(str_query) sth.execute() num_step_result_id = sth.fetch[0] #puts "********** Record found with Primary key '#{num_step_result_id}' in TestStepResult *************" dbh.disconnect() return num_step_result_id # return the step result id of the step end rescue Exception => ex $log.error("Error in setting step data to TestStep table : #{ex}") exit end |
#set_step_result_new(num_step_id, num_scenario_id, num_scenario_result_id, bool_result, num_run_length) ⇒ Object
Description : sets the step result data with execution details into Sybase Author : Chandra sekaran Arguments :
num_step_id : primary key of step
num_scenario_id : primary key of scenario
num_scenario_result_id : primary key of scenario result
bool_result : boolean value resembling the state of step result
num_run_length : steps execution time in nanoseconds
424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/friendly/cukes/framework/library/generic/performance_report.rb', line 424 def set_step_result_new(num_step_id, num_scenario_id, num_scenario_result_id, bool_result, num_run_length) num_result = bool_result ? 1 : 0 DBI.connect(@str_connection_url, DB_USER_NAME, DB_PASSWORD) do |dbh| sth = dbh.prepare("insert into TestStepResult(TestScenarioResultID,Result,RunLength,TestStepID,BuildID,TestScenarioID) values (?,?,?,?,?,?)") sth.execute(num_scenario_result_id, num_result, convert_duration(num_run_length), num_step_id, @build_id, num_scenario_id) dbh.commit dbh.disconnect() #puts "Added a record to TestStepResult table successfully" end rescue Exception => ex $log.error("(set_step_result_new)Error in setting step data to TestStepResult table : #{ex}") exit end |