Class: Semilla::FlexUnitTestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/semilla/reports.rb

Overview

Define a test case

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#classnameObject

Returns the value of attribute classname.



12
13
14
# File 'lib/semilla/reports.rb', line 12

def classname
  @classname
end

#msgObject

Returns the value of attribute msg.



12
13
14
# File 'lib/semilla/reports.rb', line 12

def msg
  @msg
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/semilla/reports.rb', line 12

def name
  @name
end

#statusObject

Returns the value of attribute status.



12
13
14
# File 'lib/semilla/reports.rb', line 12

def status
  @status
end

#timeObject

Returns the value of attribute time.



12
13
14
# File 'lib/semilla/reports.rb', line 12

def time
  @time
end

Instance Method Details

#initWith(xml) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/semilla/reports.rb', line 15

def initWith(xml)
  #parse tag
  if xml.is_a? String
    doc = REXML::Document.new xml
  else
    doc = REXML::Document.new
    doc.add_element xml
  end


  @classname = doc.root.attribute("classname").value.sub "::", "." #Change the :: to .
  @name      = doc.root.attribute("name").value                    #method name
  @time      = doc.root.attribute("time").value.to_i / 1000.0      #time to milliseconds
  @status    = doc.root.attribute("status").value                  #status
  @msg = doc.root.elements[1] if doc.root.elements.count > 0


  #If time is reported as 0 by flex unit, set to 1 millisecond
  #@time = 1/1000.0 if @time == 0
end

#toXmlObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/semilla/reports.rb', line 37

def toXml
  element = REXML::Element.new "testcase"
  element.add_attribute "classname", @classname
  element.add_attribute "name", @name
  element.add_attribute "time", @time
  element.add_attribute "status", @status
  element.add_element @msg unless @msg.nil?

  return element
end