cucumber-to-rally 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << "lib"
5
+ t.test_files = Dir["test/**/*.rb"]
6
+ end
@@ -0,0 +1,8 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "cucumber-to-rally"
3
+ s.version = "0.1.0"
4
+ s.description = "A gem to configure a connection with Cucumber to work with Rally"
5
+ s.summary = "Version 0.1.0"
6
+ s.author = "Pablo Menezes"
7
+ s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
8
+ end
@@ -0,0 +1,262 @@
1
+ $VERBOSE = nil
2
+
3
+ require 'rubygems'
4
+ require 'active_resource'
5
+ require 'logger'
6
+ require 'rally_rest_api'
7
+ require 'date'
8
+ require 'time'
9
+ require 'cucumber'
10
+ require 'fileutils'
11
+
12
+ CONTENT = '# -*- encoding : utf-8 -*-
13
+
14
+ cucumber = CucumberToRally::CucumberToRally.new
15
+
16
+ #Params to Connect on Rally
17
+ LOGIN =
18
+ PASSWORD =
19
+
20
+ #Params to create a Test Case Result
21
+ WORKSPACE =
22
+ PROJECT =
23
+ BUILD = "Cucumber"
24
+
25
+ Before do
26
+ cucumber.connect(LOGIN,PASSWORD)
27
+ end
28
+
29
+ After do |scenario|
30
+ if (scenario.failed?)
31
+ begin
32
+ if (scenario.source_tag_names.first == "@configuration")
33
+ Kernel.puts "Cenario de Configuracao. Guardando variaveis."
34
+ else
35
+ Kernel.puts "O cenario #{scenario.name} falhou!"
36
+ if (TC_ID == 0)
37
+ begin
38
+ Kernel.puts "Criando Test Case\n"
39
+ newTC = cucumber.createTestCase(WORKSPACE,PROJECT,scenario.name,"Teste de Execucao do Cucumber",OWNER,TYPE,METHOD,PRIORITY)
40
+ Kernel.puts "Caso de Teste Criado: " + newTC.to_s
41
+ cucumber.createFirstTestCaseResult(WORKSPACE,PROJECT,newTC.to_s,BUILD,"Pass")
42
+ end
43
+ else
44
+ cucumber.createTestCaseResult(WORKSPACE,PROJECT,TC_ID,BUILD,"Fail")
45
+ end
46
+ end
47
+ end
48
+ else
49
+ begin
50
+ if (scenario.source_tag_names.first == "@configuration")
51
+ Kernel.puts "Cenario de Configuracao. Guardando variaveis."
52
+ else
53
+ Kernel.puts "O cenario #{scenario.name} foi executado com sucesso!"
54
+ if (TC_ID == 0)
55
+ begin
56
+ Kernel.puts "Criando Test Case\n"
57
+ newTC = cucumber.createTestCase(WORKSPACE,PROJECT,scenario.name,"Teste de Execucao do Cucumber",OWNER,TYPE,METHOD,PRIORITY)
58
+ Kernel.puts "Caso de Teste Criado: " + newTC.to_s
59
+ cucumber.createFirstTestCaseResult(WORKSPACE,PROJECT,newTC.to_s,BUILD,"Pass")
60
+ end
61
+ else
62
+ cucumber.createTestCaseResult(WORKSPACE,PROJECT,TC_ID,BUILD,"Pass")
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end'
68
+
69
+
70
+ module CucumberToRally
71
+ class CucumberToRally
72
+
73
+ def hook
74
+ if !File.exist?("features/support/hooks.rb")
75
+ newHook = File.new("features/support/hooks.rb","w")
76
+ newHook.write(CONTENT)
77
+ end
78
+ end
79
+
80
+ def connect(login,pass)
81
+ begin
82
+ $LOGIN = login
83
+ print "Conecting with Rally...\n"
84
+ rally_logger = Logger.new STDOUT
85
+ rally_logger.level = Logger::INFO
86
+ @rally = RallyRestAPI.new(:username => login, :password => pass, :api_version => "1.29", :logger => rally_logger)
87
+ rescue
88
+ print "Error on connect. Try again...\n"
89
+ else
90
+ print "Logged with success!\n"
91
+ end
92
+ end
93
+
94
+
95
+ def findTestCaseFull(workspace,project,formattedId)
96
+ begin
97
+ print "Searching Test Case...\n"
98
+
99
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
100
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
101
+
102
+ fullResult = @rally.find(:test_case, :fetch => true, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
103
+ rescue
104
+ print "Error on search. Try again...\n"
105
+ else
106
+ if fullResult.results.length > 0
107
+ begin
108
+ print "Test Case found:#{fullResult.results.first}\n"
109
+ return fullResult.results.first
110
+ end
111
+ else
112
+ begin
113
+ print "Test Case not found\n"
114
+ return nil
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+
121
+ def findTestCaseCompact(workspace,project,formattedId,name="none")
122
+ begin
123
+ print "Searching Test Case.\n"
124
+
125
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
126
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
127
+
128
+ if (name == "none")
129
+ compactResult = @rally.find(:test_case, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
130
+ else
131
+ compactResult = @rally.find(:test_case,:workspace => ref=work, :project => ref=proj){ equal :name, name}
132
+ end
133
+ rescue
134
+ print "Error on search. Try again...\n"
135
+ else
136
+ if compactResult.results.length > 0
137
+ begin
138
+ print "Test Case found:#{compactResult.results.first}\n"
139
+ if (name == "none")
140
+ return compactResult.results.first
141
+ else
142
+ return compactResult.results.last
143
+ end
144
+ end
145
+ else
146
+ begin
147
+ print "Test Case not found...\n"
148
+ return nil
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ def findTestCaseById(workspace,project,formattedId)
155
+ begin
156
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
157
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
158
+
159
+ returnId = @rally.find(:test_case,:workspace => ref=work, :project =>ref=proj){ equal :formattedID, formattedId}
160
+
161
+ if (returnId.results.first != nil)
162
+ return true
163
+ else
164
+ return false
165
+ end
166
+
167
+ end
168
+ end
169
+
170
+ def createTestCase(workspace, project, name, description,owner=$LOGIN, type="Functional", method="Automated", priority="Critical",id=nil)
171
+ if (id != nil)
172
+ exist = findTestCaseById(workspace,project,id)
173
+ end
174
+
175
+ if (exist)
176
+ print ("Test Case exist. Skipping creation\n")
177
+
178
+ else
179
+ begin
180
+
181
+ tc = findTestCaseCompact(workspace,project,name)
182
+
183
+ print "Creating Test Case..\n"
184
+
185
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
186
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
187
+
188
+ teste = @rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
189
+
190
+ end
191
+ end
192
+
193
+ end
194
+
195
+ def findTestCaseResult(workspace,project,formattedId)
196
+ begin
197
+ print "Searching Test Case results\n"
198
+
199
+ testCase = findTestCaseCompact(workspace,project,formattedId)
200
+
201
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
202
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
203
+
204
+ testCaseResult = @rally.find(:test_case_result, :workspace => ref=work, :project => ref=proj, :fetch => true){ equal :test_case, testCase }
205
+ rescue
206
+ print "Error on search. Try again...\n"
207
+ else
208
+ if testCaseResult.results.length > 0
209
+ begin
210
+ print "Founded #{testCaseResult.results.length} Test Cases Results\n"
211
+ end
212
+ else
213
+ begin
214
+ print "No Test Case founded\n"
215
+ end
216
+ end
217
+ end
218
+ end
219
+
220
+ def createTestCaseResult(workspace,project,formattedId,build,verdict)
221
+ begin
222
+ print "Creating Test Case Result\n"
223
+
224
+ date = Time.now
225
+
226
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
227
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
228
+
229
+ tc = findTestCaseCompact(workspace,project,formattedId)
230
+
231
+ @rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)
232
+
233
+ rescue
234
+ print "Error on create Test Case Result. Try again\n"
235
+
236
+ else
237
+ print "Test Case Result created with success.\n"
238
+ end
239
+ end
240
+
241
+ def createFirstTestCaseResult(workspace,project,name,build,verdict)
242
+ begin
243
+ print "Creating first Test Case result\n"
244
+
245
+ date = Time.now
246
+
247
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
248
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
249
+
250
+ tc = findTestCaseCompact(workspace,project,"none",name)
251
+
252
+ @rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)
253
+
254
+ rescue
255
+ print "Error on create Test Case result. Try again...\n"
256
+
257
+ else
258
+ print "Test Case Result created with success.\n"
259
+ end
260
+ end
261
+ end
262
+ end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+ require 'cucumberToRally'
3
+
4
+ class CucumberTest < Test::Unit::TestCase
5
+ def testInitialize
6
+ assert_equal "Iniciando...", CucumberToRally.say
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-to-rally
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pablo Menezes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A gem to configure a connection with Cucumber to work with Rally
15
+ email:
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/cucumber-to-rally.rb
21
+ - test/cucumberToRally_test.rb
22
+ - Rakefile
23
+ - cucumber-to-rally.gemspec
24
+ homepage:
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.21
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Version 0.1.0
48
+ test_files: []
49
+ has_rdoc: