Class: Qaxqa::Testsuite

Inherits:
Object
  • Object
show all
Defined in:
lib/qaxqa/testsuite.rb

Overview

Module class to set XML parsed attributes to a suitecase object require “byebug”

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#detailsObject

Returns the value of attribute details.



7
8
9
# File 'lib/qaxqa/testsuite.rb', line 7

def details
  @details
end

#subjectObject

Returns the value of attribute subject.



7
8
9
# File 'lib/qaxqa/testsuite.rb', line 7

def subject
  @subject
end

#test_nameObject

Returns the value of attribute test_name.



7
8
9
# File 'lib/qaxqa/testsuite.rb', line 7

def test_name
  @test_name
end

#testcasesObject

Returns the value of attribute testcases.



7
8
9
# File 'lib/qaxqa/testsuite.rb', line 7

def testcases
  @testcases
end

#testsuitesObject

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

Returns:

  • (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