Class: CucumberToRally::CucumberToRally

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber-to-rally.rb

Instance Method Summary collapse

Instance Method Details

#connect(login, password) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cucumber-to-rally.rb', line 13

def connect(,password)
	begin
		$LOGIN = 
		print "Conecting with Rally...\n"
		rally_logger = Logger.new STDOUT
		rally_logger.level = Logger::INFO
		@rally = RallyRestAPI.new(:username => , :password => password, :api_version => "1.29", :logger => rally_logger)
	rescue Exception => err
		puts "Error found: " + err.message
	else
		puts "Connected to Rally!"
	end
end

#createTestCase(workspace, project, name, description, usId = nil, owner = $LOGIN, type = "Functional", method = "Automated", priority = "Critical") ⇒ Object



27
28
29
30
31
32
33
34
35
36
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
# File 'lib/cucumber-to-rally.rb', line 27

def createTestCase(workspace,project,name,description, usId = nil, owner = $LOGIN,type = "Functional", method = "Automated", priority = "Critical")

	begin

		work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
		proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project

		if usId != nil #if principal
			begin
				us = findUS(project,usId)

				if us == false #segundo if
					begin #segundo begin
						puts "No User Story found! Creating Test Case without User Story attached"
						@rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
					end #fim segundo begin
				else #else segundo if
					begin #terceiro begin
						@rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority, :work_product => us)
					end #fim terceiro begin
				end #end segundo if
			end
		else
			begin
				@rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
			end
		end

	rescue Exception => err

	puts "Error found on creation of test case: " + err.message

	else

	puts "Test Case created with success!"

	end # final do begin do método
end

#createTestCaseResult(workspace, project, formattedId, build, verdict, name = "none") ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cucumber-to-rally.rb', line 99

def createTestCaseResult(workspace,project,formattedId,build,verdict,name = "none")
	begin
		print "Creating Test Case Result\n"

		date = Time.now

		work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
		proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project

		if (name == "none")
			tc = findTestCaseCompact(workspace,project,formattedId)
		else
			tc = findTestCaseCompact(workspace,project,formattedId, name)
		end

		@rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)

	rescue Exception => err
		print "Error on create Test Case Result: "  + err.message

	else
		print "Test Case Result created with success.\n"
	end
end

#findTestCaseCompact(workspace, project, formattedId, name = "none") ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/cucumber-to-rally.rb', line 66

def findTestCaseCompact(workspace,project,formattedId,name="none")
	begin
		print "Searching Test Case.\n"

		work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
		proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project

		if (name == "none")
		compactResult = @rally.find(:test_case, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
		else
		compactResult = @rally.find(:test_case,:workspace => ref=work, :project => ref=proj){ equal :name, name}
		end
	rescue Exception => err
		print "Error on search Test Case: " + err.message
	else
		if compactResult.results.length > 0
			begin
				print "Test Case found:#{compactResult.results.first}\n"
				if (name == "none")
					return compactResult.results.first
				else
					return compactResult.results.last
				end
			end
		else
			begin
				print "Test Case not found...\n"
				return nil
			end
		end
	end
end

#findTestCaseResult(workspace, project, formattedId) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/cucumber-to-rally.rb', line 124

def findTestCaseResult(workspace,project,formattedId)
	begin
		print "Searching Test Case results\n"

		testCase = findTestCaseCompact(workspace,project,formattedId)

		work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
		proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project

		testCaseResult = @rally.find(:test_case_result, :workspace => ref=work, :project => ref=proj, :fetch => true){ equal :test_case, testCase  }
	rescue Exception => err
		print "Error on search: " + err.message
	else
		if testCaseResult.results.length > 0
			begin
				print "Found #{testCaseResult.results.length} Test Case Result(s)\n"
			end
		else
			begin
				print "No Test Case founded\n"
			end
		end
	end
end