Class: Qaxqa::Testsuite
- Inherits:
-
Object
- Object
- Qaxqa::Testsuite
- Defined in:
- lib/qaxqa/testsuite.rb
Overview
Module class to set XML parsed attributes to a suitecase object require “byebug”
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#test_name ⇒ Object
Returns the value of attribute test_name.
-
#testcases ⇒ Object
Returns the value of attribute testcases.
-
#testsuites ⇒ Object
Returns the value of attribute testsuites.
Class Method Summary collapse
- .has_suite?(node) ⇒ Boolean
- .parse(doc) ⇒ Object
-
.parse_testcases(testsuite) ⇒ Object
Parse testcases.
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
7 8 9 |
# File 'lib/qaxqa/testsuite.rb', line 7 def details @details end |
#subject ⇒ Object
Returns the value of attribute subject.
7 8 9 |
# File 'lib/qaxqa/testsuite.rb', line 7 def subject @subject end |
#test_name ⇒ Object
Returns the value of attribute test_name.
7 8 9 |
# File 'lib/qaxqa/testsuite.rb', line 7 def test_name @test_name end |
#testcases ⇒ Object
Returns the value of attribute testcases.
7 8 9 |
# File 'lib/qaxqa/testsuite.rb', line 7 def testcases @testcases end |
#testsuites ⇒ Object
Returns the value of attribute testsuites.
7 8 9 |
# File 'lib/qaxqa/testsuite.rb', line 7 def testsuites @testsuites end |
Class Method Details
.has_suite?(node) ⇒ Boolean
9 10 11 |
# File 'lib/qaxqa/testsuite.rb', line 9 def self.has_suite?(node) node.xpath('./testsuite').size > 0 end |
.parse(doc) ⇒ Object
37 38 39 40 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 66 67 |
# File 'lib/qaxqa/testsuite.rb', line 37 def self.parse(doc) root = doc.xpath("//testsuite/testsuite") main_subject = root.first.attributes["name"].value suites = [] # Parse suites root.each do |node| unless node.attributes["name"].nil? suite = Testsuite.new suite.subject = main_subject suite.test_name = node.attributes["name"].value suite.details = node.xpath("./details").text suite.testcases = self.parse_testcases node suite.testsuites = [] if self.has_suite? node subnode = node.xpath("./testsuite") subnode.each do |sn| subsuite = Testsuite.new subsuite.subject = main_subject subsuite.test_name = sn.attributes["name"].value subsuite.details = sn.xpath("./details").text subsuite.testcases = self.parse_testcases sn subsuite.testsuites = [] suite.testsuites << subsuite end end suites << suite end end return suites end |
.parse_testcases(testsuite) ⇒ Object
Parse testcases
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/qaxqa/testsuite.rb', line 14 def self.parse_testcases(testsuite) testcases = [] testsuite.xpath("./testcase").each do |tc| testcase = Testcase.new testcase.steps = [] testcase.subject = testsuite.attributes["name"].value testcase.test_name = tc.attributes["name"].value testcase.summary = tc.xpath("./summary").text testcase.preconditions = tc.xpath("./preconditions").text testcase.test_type = "Manual" # Parse steps tc.xpath("./steps/*").each do |step_node| step = Step.new step.step_number = step_node.xpath("./step_number").text step.actions = step_node.xpath("./actions").text step.expectedresults = step_node.xpath("./expectedresults").text testcase.steps << step end testcases << testcase end return testcases end |