Class: GroundControl::TestResult
- Inherits:
-
Object
- Object
- GroundControl::TestResult
- Defined in:
- lib/groundcontrol/test_result.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .read_from_directory(path_to_tests) ⇒ Object
- .read_from_xml(xml_string) ⇒ Object
- .read_tests_from_xml_document(doc) ⇒ Object
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(name, failure_message = nil) ⇒ TestResult
constructor
A new instance of TestResult.
- #success? ⇒ Boolean
Constructor Details
#initialize(name, failure_message = nil) ⇒ TestResult
Returns a new instance of TestResult.
45 46 47 48 49 50 51 52 53 |
# File 'lib/groundcontrol/test_result.rb', line 45 def initialize(name, = nil) @name = name @failed = false if @failed = true = end end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/groundcontrol/test_result.rb', line 7 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/groundcontrol/test_result.rb', line 7 def name @name end |
Class Method Details
.read_from_directory(path_to_tests) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/groundcontrol/test_result.rb', line 9 def self.read_from_directory(path_to_tests) test_results_in_directory = [] Dir.chdir(path_to_tests) Dir.glob("TEST-*.xml").each do |file| f = File.open(File.join(path_to_tests, file)) doc = Nokogiri::XML(f) f.close() test_results_in_directory += read_tests_from_xml_document(doc) end return test_results_in_directory end |
.read_from_xml(xml_string) ⇒ Object
23 24 25 26 27 |
# File 'lib/groundcontrol/test_result.rb', line 23 def self.read_from_xml(xml_string) doc = Nokogiri::XML.parse(xml_string) return read_tests_from_xml_document(doc) end |
.read_tests_from_xml_document(doc) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/groundcontrol/test_result.rb', line 29 def self.read_tests_from_xml_document(doc) tests = [] doc.xpath('//testcase').each do |testcase| failure = testcase.xpath('//failure') if failure.blank? tests << TestResult.new(testcase['name']) else tests << TestResult.new(testcase['name'], failure.first.content) end end return tests end |
Instance Method Details
#failed? ⇒ Boolean
55 56 57 |
# File 'lib/groundcontrol/test_result.rb', line 55 def failed? return @failed end |
#success? ⇒ Boolean
59 60 61 |
# File 'lib/groundcontrol/test_result.rb', line 59 def success? return true if not @failed end |