Module: Magnesium::TestResult

Included in:
Testcase
Defined in:
lib/magnesium/factor/test_result.rb

Instance Method Summary collapse

Instance Method Details

#get_expected_result(prefix, caseno) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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) ⇒ Object



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
# 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) ⇒ Object



68
69
70
71
72
73
74
# 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) ⇒ Object



76
77
78
79
80
81
# File 'lib/magnesium/factor/test_result.rb', line 76

def setelement(string)
  element = Hash.new
  element = setbox(string)
  element["action"] = "exists"
  return element
end