test_rail_integration 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/bin/test_rail_integration +4 -0
- data/lib/test_rail_integration/cli.rb +12 -0
- data/lib/test_rail_integration/generator/API_client.rb +107 -0
- data/lib/test_rail_integration/generator/connection.rb +103 -0
- data/lib/test_rail_integration/generator/project/run_test_run.rb +16 -0
- data/lib/test_rail_integration/generator/project/test_rail_data.yml +25 -0
- data/lib/test_rail_integration/generator/project.rb +33 -0
- data/lib/test_rail_integration/generator/test_case_result.rb +36 -0
- data/lib/test_rail_integration/generator/test_rail_hooks.rb +45 -0
- data/lib/test_rail_integration/generator/test_rail_tools.rb +38 -0
- data/lib/test_rail_integration/generator/test_run_parameters.rb +20 -0
- data/lib/test_rail_integration/version.rb +3 -0
- data/lib/test_rail_integration.rb +2 -0
- data/test_rail_integration.gemspec +25 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dbe2e2f64eac4da64edc9db1cb1297f08ab945b3
|
4
|
+
data.tar.gz: 84c6d54289552e5a24eb1c2949ae74708f29e9af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e71eb44a406958b6d1befba998283015771d66db35c2da60f22a04a7d38393455980820cb3325b0b9bc868e07f8ab113ad147aeb19b13437b056923d8b028d22
|
7
|
+
data.tar.gz: 60ddd527aa433f40126ad646efb721bf9e4ade577540bb12864fa2d9d57c4715804df08b6d11cc19466c058ff48fe950f98641202580359d74c7f6408d8d4605
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea/*
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# TestRailIntegration
|
2
|
+
|
3
|
+
This game made for interaction between TestRail and Ruby automation framework Cucumber+Watir
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'test_rail_integration'
|
11
|
+
gem 'thor'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install test_rail_integration
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
After installation type "test_rail_interaction perform". This command generate executable file run_test_run.rb. You should run this file with parameter - number on test run in TestRail
|
25
|
+
Fill all data in test_rail_data.yml. Next time run_test_run.rb <run_number> will generate cucumber executable file.
|
26
|
+
For perform this actions in Jenkins just create Execute shell "ruby run_test_run.rb $Testrun_id ; ./cucumber_run.sh;" where $Testrun_id its string parameter for parameterized builds.
|
27
|
+
Add TestRail::Hook.update_test_rail(scenario) into after hook.
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/kirikami/test_rail_integration/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'generator/project'
|
3
|
+
|
4
|
+
module TestRailIntegration
|
5
|
+
class CLI < Thor
|
6
|
+
desc "perform", "Creates project for interaction with TestRail"
|
7
|
+
|
8
|
+
def perform
|
9
|
+
TestRailIntegration::TestTail::Generators::Project.copy_file('run_test_run.rb')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# TestRail API binding for Ruby (API v2, available since TestRail 3.0)
|
3
|
+
#
|
4
|
+
# Learn more:
|
5
|
+
#
|
6
|
+
# http://docs.gurock.com/testrail-api2/start
|
7
|
+
# http://docs.gurock.com/testrail-api2/accessing
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'net/http'
|
11
|
+
require 'net/https'
|
12
|
+
require 'uri'
|
13
|
+
require 'json'
|
14
|
+
|
15
|
+
module TestRail
|
16
|
+
class APIClient
|
17
|
+
@url = ''
|
18
|
+
@user = ''
|
19
|
+
@password = ''
|
20
|
+
|
21
|
+
attr_accessor :user
|
22
|
+
attr_accessor :password
|
23
|
+
|
24
|
+
def initialize(connection_data)
|
25
|
+
base_url = connection_data[:url]
|
26
|
+
unless base_url.match(/\/$/)
|
27
|
+
base_url += '/'
|
28
|
+
end
|
29
|
+
@url = base_url + 'index.php?/api/v2/'
|
30
|
+
@user = connection_data[:username]
|
31
|
+
@password = connection_data[:password]
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Send Get
|
36
|
+
#
|
37
|
+
# Issues a GET request (read) against the API and returns the result
|
38
|
+
# (as Ruby hash).
|
39
|
+
#
|
40
|
+
# Arguments:
|
41
|
+
#
|
42
|
+
# uri The API method to call including parameters
|
43
|
+
# (e.g. get_case/1)
|
44
|
+
#
|
45
|
+
def send_get(uri)
|
46
|
+
_send_request('GET', uri, nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Send POST
|
51
|
+
#
|
52
|
+
# Issues a POST request (write) against the API and returns the result
|
53
|
+
# (as Ruby hash).
|
54
|
+
#
|
55
|
+
# Arguments:
|
56
|
+
#
|
57
|
+
# uri The API method to call including parameters
|
58
|
+
# (e.g. add_case/1)
|
59
|
+
# data The data to submit as part of the request (as
|
60
|
+
# Ruby hash, strings must be UTF-8 encoded)
|
61
|
+
#
|
62
|
+
def send_post(uri, data)
|
63
|
+
_send_request('POST', uri, data)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def _send_request(method, uri, data)
|
68
|
+
url = URI.parse(@url + uri)
|
69
|
+
if method == 'POST'
|
70
|
+
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
71
|
+
request.body = JSON.dump(data)
|
72
|
+
else
|
73
|
+
request = Net::HTTP::Get.new(url.path + '?' + url.query)
|
74
|
+
end
|
75
|
+
request.basic_auth(@user, @password)
|
76
|
+
request.add_field('Content-Type', 'application/json')
|
77
|
+
|
78
|
+
conn = Net::HTTP.new(url.host, url.port)
|
79
|
+
if url.scheme == 'https'
|
80
|
+
conn.use_ssl = true
|
81
|
+
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
82
|
+
end
|
83
|
+
response = conn.request(request)
|
84
|
+
|
85
|
+
if response.body && !response.body.empty?
|
86
|
+
result = JSON.parse(response.body)
|
87
|
+
else
|
88
|
+
result = {}
|
89
|
+
end
|
90
|
+
|
91
|
+
if response.code != '200'
|
92
|
+
if result && result.key?('error')
|
93
|
+
error = '"' + result['error'] + '"'
|
94
|
+
else
|
95
|
+
error = 'No additional error message received'
|
96
|
+
end
|
97
|
+
raise APIError.new('TestRail API returned HTTP %s (%s)' %
|
98
|
+
[response.code, error])
|
99
|
+
end
|
100
|
+
|
101
|
+
result
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class APIError < StandardError
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require_relative 'API_client'
|
2
|
+
require_relative 'test_case_result'
|
3
|
+
require_relative 'test_rail_tools'
|
4
|
+
|
5
|
+
module TestRail
|
6
|
+
class Connection
|
7
|
+
|
8
|
+
ASSIGNED_TO ||= TestRailTools.test_rail_data[:assigned_to]
|
9
|
+
TEST_SUITE ||= TestRailTools.test_rail_data[:test_suite]
|
10
|
+
CONNECTION_DATA ||= TestRailTools.test_rail_data[:connection_data]
|
11
|
+
PROJECT_ID ||= TestRailTools.test_rail_data[:project]
|
12
|
+
TEST_RUN_ID ||= TestRailTools.test_rail_data[:test_run_id]
|
13
|
+
IN_PROGRESS ||= TestRailTools.test_rail_data[:in_progress]
|
14
|
+
NO_TEST_RAIL ||= 0
|
15
|
+
|
16
|
+
#
|
17
|
+
# Creates connection to TestRail server
|
18
|
+
#
|
19
|
+
# client = TestRail::APIClient.new('<TestRail server>',"<User email>","<User password>")
|
20
|
+
#
|
21
|
+
def self.client
|
22
|
+
@client_test_rail ||= TestRail::APIClient.new(CONNECTION_DATA)
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Send test result to TestRail for current test run
|
27
|
+
# client.send_post("add_result_for_case/<number_of test run>/<test case id>", <result that pushes>)
|
28
|
+
#
|
29
|
+
# client.send_post("add_result_for_case/12/3131", status_id: '1', comment: "Test passed" )
|
30
|
+
#
|
31
|
+
def self.commit_test_result(test_case_result)
|
32
|
+
client.send_post("add_result_for_case/#{TEST_RUN_ID}/#{test_case_result.test_case_id}", test_case_result.to_test_rail_api)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Obtaining of all previous test results for current test case
|
37
|
+
#
|
38
|
+
# client.send_get("get_results_for_case/12/3534")
|
39
|
+
#
|
40
|
+
def self.get_test_result(case_id)
|
41
|
+
client.send_get("get_results_for_case/#{test_run_id}/#{case_id}")
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Parse results and returns Failed if this test was marked as failed.
|
46
|
+
#
|
47
|
+
def self.get_previous_test_result(case_id)
|
48
|
+
test_results = get_test_result(case_id).map { |status_hash| status_hash["status_id"] }
|
49
|
+
status = TestCaseResult::FAILED if test_results.include?(TestCaseResult::FAILED)
|
50
|
+
status ||= TestCaseResult::PASS if test_results.first == TestCaseResult::PASS
|
51
|
+
status ||= TestCaseResult::NEW
|
52
|
+
status
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Get ID of all test cases from current test run
|
57
|
+
#
|
58
|
+
# cases = client.send_get("get_tests/12")
|
59
|
+
#
|
60
|
+
def self.cases_id(test_run_id)
|
61
|
+
cases = client.send_get("get_tests/#{test_run_id}")
|
62
|
+
cases.map { |test_case| test_case["case_id"] }
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Setting up test run id
|
67
|
+
#
|
68
|
+
def self.test_run_id=(test_run_id)
|
69
|
+
@test_run_id = test_run_id
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Getting test run id value
|
74
|
+
#
|
75
|
+
def self.test_run_id
|
76
|
+
@test_run_id ||= TEST_RUN_ID
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Getting information about test run
|
81
|
+
#
|
82
|
+
def self.test_run_data
|
83
|
+
client.send_get("get_run/#{test_run_id}")
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Get test run name
|
88
|
+
#
|
89
|
+
def self.test_run_name
|
90
|
+
test_run_data["name"]
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Changing name of test run from <test run name> in progress to <test run name>
|
95
|
+
#
|
96
|
+
# VN LIVE_TEST in progress => VN LIVE_TEST
|
97
|
+
#
|
98
|
+
def self.change_test_run_name
|
99
|
+
new_name = test_run_name.gsub(IN_PROGRESS, "")
|
100
|
+
client.send_post("update_run/#{test_run_id}", { name: new_name })
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test_rail_integration'
|
3
|
+
require 'thor'
|
4
|
+
require 'test_rail_integration/generator/API_client'
|
5
|
+
require 'test_rail_integration/generator/connection'
|
6
|
+
require 'test_rail_integration/generator/test_rail_tools'
|
7
|
+
|
8
|
+
module TestRail
|
9
|
+
unless TestRailIntegration::TestTail::Generators::Project.test_rail_data_file_exist?
|
10
|
+
TestRailIntegration::TestTail::Generators::Project.copy_file("test_rail_data.yml")
|
11
|
+
raise "Please fill all required data in test rail data yml file"
|
12
|
+
end
|
13
|
+
id_of_run = ARGV.shift
|
14
|
+
TestRailTools.prepare_config(id_of_run)
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
:connection_data:
|
2
|
+
:url: #put here url of your TestRail server
|
3
|
+
:username: #TestRail username
|
4
|
+
:password: #Password for TestRail user
|
5
|
+
|
6
|
+
:project: # Test project id can be found in Test Rail
|
7
|
+
:test_suite: # Test suite id can be found in Test Rail
|
8
|
+
:assigned_to: # Id of person could be found in Test Rail
|
9
|
+
:description_of_run: "Automatically generated report by auto tests."
|
10
|
+
|
11
|
+
:status_comment: 0
|
12
|
+
:test_pass: 1
|
13
|
+
:need_to_retest: 4
|
14
|
+
:test_failed: 5
|
15
|
+
:new_test: 0
|
16
|
+
|
17
|
+
:test_passed_comment: "test **passed**"
|
18
|
+
:test_failed_comment: "test **failed**"
|
19
|
+
|
20
|
+
:ventures: #values for generating parametrized url for running test
|
21
|
+
:environments: #values for generating parametrized url for running test
|
22
|
+
|
23
|
+
:in_progress: " (in progress)" #value for changing test run name for monitoring complete of test run
|
24
|
+
|
25
|
+
:test_run_id: 0 #parametrized test run from "ruby run_test_run.rb <testrun number>"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
module TestRailIntegration
|
5
|
+
module TestTail
|
6
|
+
module Generators
|
7
|
+
class Project < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
desc "Generates files that contains information about TestRail"
|
11
|
+
|
12
|
+
def self.source_root
|
13
|
+
File.dirname(__FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.test_rail_data_file_exist?
|
17
|
+
File.exists?("config/data/test_rail_data.yml")
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.copy_file(file_name, root = nil)
|
21
|
+
if file_name == "test_rail_data.yml"
|
22
|
+
FileUtils.mkdir("config/data")
|
23
|
+
end
|
24
|
+
if root
|
25
|
+
FileUtils.cp("#{source_root}/project/#{file_name}", "#{root}/#{file_name}")
|
26
|
+
else
|
27
|
+
FileUtils.cp("#{source_root}/project/#{file_name}", "#{file_name}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'test_rail_tools'
|
2
|
+
|
3
|
+
module TestRail
|
4
|
+
class TestCaseResult
|
5
|
+
|
6
|
+
attr_accessor :test_case_id, :title, :comment, :exception_message
|
7
|
+
|
8
|
+
COMMENT_STATUS ||= TestRail::TestRailTools.test_rail_data[:status_comment]
|
9
|
+
PASS ||= TestRail::TestRailTools.test_rail_data[:test_pass]
|
10
|
+
FAILED ||= TestRail::TestRailTools.test_rail_data[:test_failed]
|
11
|
+
NEW ||= TestRail::TestRailTools.test_rail_data[:new_test]
|
12
|
+
PASS_COMMENT ||= TestRail::TestRailTools.test_rail_data[:test_passed_comment]
|
13
|
+
FAILED_COMMENT ||= TestRail::TestRailTools.test_rail_data[:test_failed_comment]
|
14
|
+
|
15
|
+
COMMENT ||= { :pass => { status: PASS, comment: PASS_COMMENT },
|
16
|
+
:fail => { status: FAILED, comment: FAILED_COMMENT },
|
17
|
+
:unchanged_pass => { status: COMMENT_STATUS, comment: PASS_COMMENT }
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(test_case_id, title)
|
21
|
+
self.test_case_id = test_case_id
|
22
|
+
self.title = title
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_test_rail_api
|
26
|
+
comment_message = "\"#{self.title}\" #{self.comment[:comment]}"
|
27
|
+
comment_message += "\n Exception : #{self.exception_message}" unless self.exception_message.nil?
|
28
|
+
if self.comment[:status] == COMMENT_STATUS
|
29
|
+
{ comment: comment_message }
|
30
|
+
else
|
31
|
+
{ status_id: self.comment[:status], comment: comment_message }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_rail_integration/generator/connection'
|
2
|
+
|
3
|
+
module TestRail
|
4
|
+
class Hook
|
5
|
+
|
6
|
+
TEST_RAIL_ID_REGEX ||= /^@C\d+/
|
7
|
+
|
8
|
+
|
9
|
+
def self.update_test_rail(scenario)
|
10
|
+
test_case_id = scenario.source_tag_names.find { |e| e.match(TEST_RAIL_ID_REGEX) }[2..-1]
|
11
|
+
|
12
|
+
prev_result = TestRail::Connection.get_previous_test_result(test_case_id)
|
13
|
+
both_run_result = scenario.passed? || RunInformation.second_run_result == 0
|
14
|
+
test_case_result = TestRail::TestCaseResult.new(test_case_id, scenario.title)
|
15
|
+
|
16
|
+
test_case_result.comment = TestRail::TestCaseResult::COMMENT[:pass] if passed_result?(both_run_result, prev_result)
|
17
|
+
test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:unchanged_pass] if unchanged_pass_result?(both_run_result, prev_result)
|
18
|
+
|
19
|
+
if failed_result?(both_run_result)
|
20
|
+
test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:fail]
|
21
|
+
test_case_result.exception_message = scenario.steps.exception rescue nil
|
22
|
+
end
|
23
|
+
|
24
|
+
raise("Invalide test case result : scenario.passed? #{scenario.passed?}, both_run_result? #{both_run_result} prev_result? #{prev_result}") if test_case_result.comment.nil?
|
25
|
+
|
26
|
+
TestRail::Connection.commit_test_result(test_case_result)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.failed_result?(result)
|
30
|
+
!result
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.passed_result?(result, prev_result)
|
34
|
+
result && prev_result != TestRail::TestCaseResult::FAILED
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.unchanged_pass_result?(result, prev_result)
|
38
|
+
result && prev_result == TestRail::TestCaseResult::FAILED
|
39
|
+
end
|
40
|
+
|
41
|
+
at_exit do
|
42
|
+
TestRail::Connection.change_test_run_name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require_relative 'connection'
|
3
|
+
require_relative 'test_run_parameters'
|
4
|
+
|
5
|
+
module TestRail
|
6
|
+
class TestRailTools
|
7
|
+
|
8
|
+
CONFIG_PATH ||= ('config/data/test_rail_data.yml')
|
9
|
+
|
10
|
+
def self.test_rail_data
|
11
|
+
YAML.load(File.open(CONFIG_PATH))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.generate_cucumber_execution_file(id_of_run)
|
15
|
+
parameters = TestRunParameters.new
|
16
|
+
command = "cucumber -p lazada.#{parameters.venture}.#{parameters.environment} TESTRAIL=1 --color -f json -o cucumber.json -t " + Connection.cases_id(id_of_run).map { |id| "@C"+id.to_s }.join(",")
|
17
|
+
cucumber_file = File.new("cucumber_run.sh", "w")
|
18
|
+
cucumber_file.chmod(0700)
|
19
|
+
cucumber_file.write("#!/bin/sh\n")
|
20
|
+
cucumber_file.write(command)
|
21
|
+
cucumber_file.close
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.write_test_run_id(test_run_id)
|
25
|
+
testrail_data_file = File.read(CONFIG_PATH).gsub(/^:test_run_id: \d+/, ":test_run_id: #{test_run_id}")
|
26
|
+
config_file = File.open(CONFIG_PATH, "w")
|
27
|
+
config_file.write (testrail_data_file)
|
28
|
+
config_file.close
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.prepare_config(run_id)
|
32
|
+
Connection.test_run_id = run_id
|
33
|
+
write_test_run_id(run_id)
|
34
|
+
generate_cucumber_execution_file(run_id)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'API_client'
|
2
|
+
|
3
|
+
module TestRail
|
4
|
+
class TestRunParameters
|
5
|
+
VENTURE_REGEX ||= /vn|id|ph|my|sg|th/
|
6
|
+
ENVIRONMENT_REGEX ||= /live_test|staging|showroom/
|
7
|
+
|
8
|
+
attr_accessor :environment, :venture
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
parameters = Connection.test_run_name.downcase.match(/^(#{VENTURE_REGEX}) (#{ENVIRONMENT_REGEX})*/)
|
12
|
+
begin
|
13
|
+
@venture = parameters[1]
|
14
|
+
@environment = parameters[2]
|
15
|
+
rescue Exception
|
16
|
+
raise ("The test run name is not valid. Format: 'venture env description'")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'test_rail_integration/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "test_rail_integration"
|
8
|
+
spec.version = TestRailIntegration::VERSION
|
9
|
+
spec.authors = ["Kirikami"]
|
10
|
+
spec.email = ["naumenko.ruslan@outlook.com"]
|
11
|
+
spec.summary = %q{Gem for integration between framework and TestRail API}
|
12
|
+
spec.description = %q{Setups status of tests into TestRail after each scenario}
|
13
|
+
spec.homepage = "https://github.com/Kirikami/test_rail_integration"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "thor", "~> 0.17"
|
24
|
+
spec.add_development_dependency "fileutils", "~> 0.7"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test_rail_integration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirikami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.17'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.17'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fileutils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
description: Setups status of tests into TestRail after each scenario
|
70
|
+
email:
|
71
|
+
- naumenko.ruslan@outlook.com
|
72
|
+
executables:
|
73
|
+
- test_rail_integration
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/test_rail_integration
|
84
|
+
- lib/test_rail_integration.rb
|
85
|
+
- lib/test_rail_integration/cli.rb
|
86
|
+
- lib/test_rail_integration/generator/API_client.rb
|
87
|
+
- lib/test_rail_integration/generator/connection.rb
|
88
|
+
- lib/test_rail_integration/generator/project.rb
|
89
|
+
- lib/test_rail_integration/generator/project/run_test_run.rb
|
90
|
+
- lib/test_rail_integration/generator/project/test_rail_data.yml
|
91
|
+
- lib/test_rail_integration/generator/test_case_result.rb
|
92
|
+
- lib/test_rail_integration/generator/test_rail_hooks.rb
|
93
|
+
- lib/test_rail_integration/generator/test_rail_tools.rb
|
94
|
+
- lib/test_rail_integration/generator/test_run_parameters.rb
|
95
|
+
- lib/test_rail_integration/version.rb
|
96
|
+
- test_rail_integration.gemspec
|
97
|
+
homepage: https://github.com/Kirikami/test_rail_integration
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.2.2
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Gem for integration between framework and TestRail API
|
121
|
+
test_files: []
|