Class: Magnesium::Testcase
- Inherits:
-
Object
- Object
- Magnesium::Testcase
- Includes:
- TestData, TestResult, TestSite, TestStep, TestUI
- Defined in:
- lib/magnesium/factor/test_case.rb
Instance Method Summary collapse
-
#initialize(p, c) ⇒ Testcase
constructor
A new instance of Testcase.
- #new_folder(path) ⇒ Object
-
#run ⇒ Object
1.
Methods included from TestUI
Methods included from TestResult
#get_expected_result, #get_real_result, #setbox, #setelement
Methods included from TestStep
Methods included from TestSite
Methods included from TestData
Constructor Details
#initialize(p, c) ⇒ Testcase
Returns a new instance of Testcase.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/magnesium/factor/test_case.rb', line 21 def initialize(p,c) @prefix = p @caseno = c new_folder("#{Config.config["temp"]}nodes_hierarchy") #new folder id new_folder("#{Config.config["temp"]}#{TestLink.find_path(@prefix,@caseno).split(/\//)[0]}/#{TestLink.find_path(@prefix,@caseno).split(/\//)[1]}") #download attachment ssh = SSH.new ssh.host = Config.config["testlink"]["host"] ssh.username = Config.config["testlink"]["host_account"] ssh.pwd = Config.config["testlink"]["host_pwd"] ssh.local ="#{Config.config["temp"]}#{TestLink.find_path(@prefix,@caseno).split(/\//)[0]}/#{TestLink.find_path(@prefix,@caseno).split(/\//)[1]}/" ssh.server = "#{Config.config["testlink"]["install_path"]}upload_area/#{TestLink.find_path(@prefix,@caseno)}" ssh.download_file #factor @data = generate_data(@prefix,@caseno) # @data.prefix = @prefix # @data.caseno = @caseno # @data.generate @ui = generate_UI(@prefix,@caseno) @site = generate_site(@prefix,@caseno) @step = generate_step(@prefix,@caseno) @expected_result = get_expected_result(@prefix,@caseno) end |
Instance Method Details
#new_folder(path) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/magnesium/factor/test_case.rb', line 49 def new_folder(path) if (File.exist? path) puts "folder exist!" else Dir.mkdir(path) end end |
#run ⇒ Object
1
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 |
# File 'lib/magnesium/factor/test_case.rb', line 57 def run() #1 begin #2 @data.each do |data_key,data_value| #3 browser_type = Config.config["browser"]["value"] @browser = Watir::Browser.new :chrome if browser_type == "chrome" @step.each do |step_key,step_value| #4 @tempdata = data_value.hash[step_key] unless data_value.hash[step_key].nil? unless step_value.to_s.eql? 'goto' #5 @ui.each do |ui_key,ui_value| @temptype = ui_value.container_type @temptitle = ui_value.container_title #if popup # unless ui_value.hash_element[step_key].nil? @tempelement = ui_value.hash_element[step_key] @templocate = ui_value.hash_locate[step_key] @tempvalue = ui_value.hash_value[step_key] @tempaction = ui_value.hash_action[step_key] unless ui_value.hash_box[step_key].nil? @tempbox = ui_value.hash_box[step_key] else @tempbox = Array.new end break end # end #ui #real run unless @tempelement.eql? 'js' fa = Factory.creator(@tempelement) fa.box = @tempbox fa.browser = @browser fa.generate fa.element(@templocate,@tempvalue) if @temptype == 'common' fa.execute(@tempaction,@tempdata) else dealpopup(@browser,@temptitle,fa,@tempaction,@tempdata) end else #if js has nothing to do with frame #if popip has no js #TODO execute_js(@browser,@tempvalue) end #unless js #end of real run else #5 @browser.goto @site[step_key].to_s #gotoBrowser(@browser,@site[step_key].to_s) end #5 end #4 #generate result get_real_result(@prefix,@caseno,@browser) #end of per data test @browser.close # closeBrowser(@browser) end #3 #delete temp fodler FileUtils.rm_rf "#{Config.config["temp"]}nodes_hierarchy/" #end #3 # rescue # error end #2 end |