module Magnesium::TestResult

Public Instance Methods

get_expected_result(prefix,caseno) click to toggle source
# File lib/magnesium/factor/test_result.rb, line 6
    def get_expected_result(prefix,caseno)
      begin
        tc_id = TestLink.find_tcase(prefix,caseno)
        tv_id = TestLink.find_version(tc_id)

        TestLink.find_step_result(tv_id).each do |row|
          row.map do |k,v|
            @expected_result = v
          end
        end

        box = Array.new
        expect = Hash.new
        unless @expected_result.split(/\<p\>\r\n\t/)[1].nil?
          r = @expected_result.split(/\<p\>\r\n\t/)[1].split(/\<\/p\>/)[0].split(/\=\&gt\;/)
          if r.size > 1
            i = 0
            until i>r.size-2
              box.push setbox(r[i])
              i = i+1
            end
          end
          expect["box"] = box
          expect["element"] = setelement(r[r.size-1])#basic
          return expect
        else
          #error
          puts '...'
        end
#      rescue
#        error
        #ensure
      end
    end
get_real_result(prefix,caseno,browser) click to toggle source
# File lib/magnesium/factor/test_result.rb, line 41
   def get_real_result(prefix,caseno,browser)
     begin
       hash = get_expected_result(prefix,caseno)
       #puts hash
       data = nil

       fa = Factory.creator(hash["element"]["name"].to_s)

       fa.box = hash["box"]
       fa.browser = browser
       fa.generate
       fa.element(hash["element"]["locate"],hash["element"]["value"])
       if fa.execute(hash["element"]["action"],data)
         @status = "p"
         @notes = "pass"
       else
         @status = "f"
         @notes = "fail"
       end
       Feedback.new(prefix,caseno,"zhou_meichen",@status,@notes)
#     rescue
#       error
       #ensure
     end
   end
setbox(string) click to toggle source
# File lib/magnesium/factor/test_result.rb, line 68
def setbox(string)
  box = Hash.new
  box["name"] = string.split(/\(/)[0]
  box["locate"] = string.split(/\(/)[1].split(/\:/)[0]
  box["value"] = string.split(/\(/)[1].split(/\:/)[1].split(/\)/)[0]
  return box
end
setelement(string) click to toggle source
# File lib/magnesium/factor/test_result.rb, line 76
def setelement(string)
  element = Hash.new
  element = setbox(string)
  element["action"] = "exists"
  return element
end