class BuildExtractor

Public Class Methods

new(str_connection_url, str_directory_path, num_host_data_id) click to toggle source

Description : invoked automatically when an object of the class type is created Author : Chandra sekaran Arguments :

str_connection_url : connection url for DB
str_directory_path : json report files directory path
num_host_data_id   : primary key of HostData table
# File lib/friendly/build_extractor.rb, line 39
def initialize(str_connection_url, str_directory_path, num_host_data_id)
  @str_directory_path = str_directory_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 = ""
  @str_user_name = ""
  @str_password = ""
  split_connection_url(str_connection_url)

  @num_host_data_id = num_host_data_id
end

Public Instance Methods

convert_duration(num_duration) click to toggle source

Description : converts nanoseconds to seconds Author : Chandra sekaran Arguments :

num_duration        : time in nanoseconds

Return Argument : time in seconds

# File lib/friendly/build_extractor.rb, line 575
def convert_duration(num_duration)
  num_duration/(1000*1000*1000) #.to_f    # convert nanosecond to second
end
format_file_path(str_fileabs_path) click to toggle source

Description : formats the file path by replacing “" with ”/“ Author : Chandra sekaran Arguments :

str_fileabs_path : absolute path of file

Return value :

str_file_path    : formatted absolute path of file
# File lib/friendly/build_extractor.rb, line 607
def format_file_path(str_fileabs_path)
  str_file_path = str_fileabs_path
  str_file_path.each_char do |letter|     # replace all the escape sequences
    case letter
      when /[\a]/
        str_file_path[letter] = "/a"
      when /[\e]/
        str_file_path[letter] = "/e"
      when /[\b]/
        str_file_path[letter] = "/b"
      when /[\cx]/
        str_file_path[letter] = "/cx"
      when /[\f]/
        str_file_path[letter] = "/f"
      when /[\n]/
        str_file_path[letter] = "/n"
      when /[\nnn]/
        #str_file_path[letter] = "/nnn" # not required as \n is given
      when /[\r]/
        str_file_path[letter] = "/r"
      when /[\s]/
        str_file_path[letter] = "/t"   # it is taking "\t" as "\s"
      when /[\t]/
        str_file_path[letter] = "/t"
      when "\\"
        str_file_path[letter] = "/"
     #when /[\v]/                       #  not required due to expression error
     #str_file_path[letter] = "/v"    #  not required due to expression error
     #when /[\x]/                       #  not required due to expression error
     #str_file_path[letter] = "/x"    #  not required due to expression error
     #when /[\xnn]/                     #  not required due to expression error
     #str_file_path[letter] = "/xnn"  #  not required due to expression error
    end
  end
  return str_file_path
rescue Exception => ex
  puts("Error in formatting file path (#{str_file_path}) : #{ex}")
  exit
end
get_host_data() click to toggle source

Description : gets the host data from Sybase based on current execution host Author : Chandra sekaran Return Arguments :

num_host_id   : primary key the host
# File lib/friendly/build_extractor.rb, line 231
def get_host_data
  # as of now I took hostid primary key for getting the current host where the execution has been made
  # and I took BROWSER for selecting under the assumption that each browser executes on different host machines
  # if you are using some other parameter, kindly uncomment and update the required fields
  #DBI.connect(@str_connection_url, @str_user_name, @str_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}'"
  #  str_query = "select HostDataID from HostData where HostDataID=#{@num_host_data_id}"
  #  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
  @num_host_data_id
rescue Exception => ex
  puts("Error in getting host data from HostData table: #{ex}")
  exit
end
parse_json() click to toggle source

Description : parses the json object saves the required execution data into Sybase DB Author : Chandra sekaran

# File lib/friendly/build_extractor.rb, line 105
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
                                                                                                                            # above element["tags"][0]["name"] takes the first tag which should be the scenario id (here @tc_<scenarioid>)

        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
  puts("Error while parsing JSON : #{ex}")
  exit
end
reset_build(num_run_length, num_pass_count, num_fail_count, num_skip_count, bool_result) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 260
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, @str_user_name, @str_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
  puts("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) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 352
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, @str_user_name, @str_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
  puts("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) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 444
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, @str_user_name, @str_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
  puts("Error in resetting scenario data to TestScenarioResult table : #{ex}")
  exit
end
reset_step_result(bool_result, num_run_length, num_step_result_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 554
def reset_step_result(bool_result, num_run_length, num_step_result_id)
  num_result = bool_result ? 1 : 0
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in resetting step results data in TestStepResult table : #{ex}")
  exit
end
save_build_data() click to toggle source

Description : function that creates performance report data and stores it in Sybase Author : Chandra sekaran

# File lib/friendly/build_extractor.rb, line 582
def save_build_data
  puts "Extracting build data ...\nThis might take a moment, please wait"
  set_build       # set Build data only once for each execution (Single or Parallel)
  Dir["#{format_file_path(@str_directory_path)}/*.json"].each do |path|
    puts "Extracting build execution data from '#{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
  puts "\nThe build execution data for the build ID=#{@build_id} are saved into #{@str_db} DataBase successfully"
rescue Exception => ex
  puts("Error while creating report : #{ex}")
  exit
end
set_build() click to toggle source

Description : sets the build data with default details into Sybase Author : Chandra sekaran

# File lib/friendly/build_extractor.rb, line 204
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, @str_user_name, @str_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
  puts("Error in setting build data to BuildData table: #{ex}")
  exit
end
set_feature(str_feature_name) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 283
def set_feature(str_feature_name)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in setting feature data to TestFeature table : #{ex}")
  exit
end
set_feature_result(num_feature_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 316
def set_feature_result(num_feature_id)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in setting feature result data to TestFeatureResult table : #{ex}")
  exit
end
set_scenario(str_scenario_name, str_qa_complete_id, str_feature_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 377
def set_scenario(str_scenario_name, str_qa_complete_id, str_feature_id)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in setting scenario data to TestScenario table : #{ex}")
  exit
end
set_scenario_result(num_scenario_id, num_feature_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 413
def set_scenario_result(num_scenario_id, num_feature_id)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in setting scenario data to TestScenarioResult table : #{ex}")
  exit
end
set_step(str_step_name, str_scenario_id, num_scenario_result_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 469
def set_step(str_step_name, str_scenario_id, num_scenario_result_id)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("Error in setting step data to TestStep table : #{ex}")
  exit
end
set_step_result(num_step_id, num_scenario_id, num_scenario_result_id) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 527
def set_step_result(num_step_id, num_scenario_id, num_scenario_result_id)
  DBI.connect(@str_connection_url, @str_user_name, @str_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
  puts("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) click to toggle source

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
# File lib/friendly/build_extractor.rb, line 504
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, @str_user_name, @str_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
  puts("(set_step_result_new)Error in setting step data to TestStepResult table : #{ex}")
  exit
end
split_connection_url(str_connection_url) click to toggle source

Description : extracts connection url, username and password from the input connection url Author : Chandra sekaran

# File lib/friendly/build_extractor.rb, line 59
def split_connection_url(str_connection_url)
  tmp_arr = str_connection_url.split(";")
  num_count = 0
  ["dbi"].each do |key|
    if str_connection_url.downcase.include? key
      tmp_arr.each do |ele|
        @str_connection_url = ele.split(";").first.strip + ";" if ele.downcase.include? key
      end
    else num_count += 1
    end
  end
  raise "Invalid connection url, it doesn't include dbi field : #{str_connection_url}" if num_count == ["dbi"].size
  num_count = 0
  ["dbn", "database", "dbname"].each do |key|
    if str_connection_url.downcase.include? key
      tmp_arr.each do |ele|
        if ele.downcase.include? key
          @str_connection_url << "DBN=" + ele.split("=").last.strip + ";"
          @str_db = ele.split("=").last.strip
        end
      end
    else num_count += 1
    end
  end
  raise "Invalid connection url, it doesn't include database field : #{str_connection_url}" if num_count == ["dbi"].size
  num_count = 0
  ["uid", "userid", "username"].each do |key|
    if str_connection_url.downcase.include? key
      tmp_arr.each do |ele|
        @str_user_name = ele.split("=").last.strip if ele.downcase.include? key
      end
    else num_count += 1
    end
  end
  ["pwd", "password"].each do |key|
    if str_connection_url.downcase.include? key
      tmp_arr.each do |ele|
        @str_password = ele.split("=").last.strip if ele.downcase.include? key
      end
    end
  end
end