perfecto-reporting 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +13 -0
- data/README.md +68 -0
- data/lib/perfecto-reporting.rb +20 -20
- data/lib/perfecto-reporting/client/PerfectoReportiumClient.rb +168 -168
- data/lib/perfecto-reporting/client/ReportiumClientFactory.rb +8 -8
- data/lib/perfecto-reporting/client/constants.rb +6 -6
- data/lib/perfecto-reporting/exceptions/ReportiumException.rb +11 -11
- data/lib/perfecto-reporting/license.txt +13 -0
- data/lib/perfecto-reporting/model/CustomField.rb +10 -10
- data/lib/perfecto-reporting/model/Job.rb +20 -20
- data/lib/perfecto-reporting/model/PerfectoExecutionContext.rb +112 -112
- data/lib/perfecto-reporting/model/Project.rb +19 -19
- data/lib/perfecto-reporting/test/TestContext.rb +64 -64
- data/lib/perfecto-reporting/test/result/TestResult.rb +13 -13
- data/lib/perfecto-reporting/test/result/TestResultFactory.rb +36 -36
- data/lib/perfecto-reporting/test/result/TestResultFailure.rb +39 -39
- data/lib/perfecto-reporting/test/result/TestResultSuccess.rb +17 -17
- data/lib/perfecto-reporting/version.rb +7 -7
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a114204836540cc29a9c2519876a42923876039c
|
4
|
+
data.tar.gz: ee18e96e0cab1a2718547ef5d75b34371711a8e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2495c4fcdf0790b9525abb3b7162e6316b7e0e6b608acb1f17fc3d99c215c333cea54ad4027dc1a26ac317631ddb4b4af74e21f0fcbb8f2678ae47c1163e1dc
|
7
|
+
data.tar.gz: e8546b4371f24f78f6d0761ccf690b1e63b4176228d1eefd5d52223081847fe4f335c6ac303299abd4cb7849bd269ecd9de78e2d82e2e65af1b8d9feb089df00
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2019 Perfecto
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
## Reporting SDK for Ruby Programming language
|
2
|
+
|
3
|
+
**Updates:**
|
4
|
+
|
5
|
+
- 31/8 init repo
|
6
|
+
- 1/9 Uploaded PerfectoReportingClient + reportingTests.
|
7
|
+
- Added documentation (internal, not for the community).
|
8
|
+
- 4/9 Added Connection/SsoTokenProducer (Look documentation for windows [certification errors](## Troubleshoot for windows certification error (OpenSSL::SSL::SSLError))).
|
9
|
+
- 5/9 Added gem (without httpclient) .
|
10
|
+
- 6/9 Gem without httpclient published.
|
11
|
+
|
12
|
+
|
13
|
+
*Dependencies:*
|
14
|
+
|
15
|
+
require reporting statement: <br/>
|
16
|
+
`require_relative '../gem/Perfecto-Reporting'`
|
17
|
+
|
18
|
+
**Usage:**
|
19
|
+
|
20
|
+
Initialize a new client:
|
21
|
+
```Ruby
|
22
|
+
def create_reporting_client
|
23
|
+
perfectoExecutionContext = PerfectoExecutionContext.new(PerfectoExecutionContextBuilder
|
24
|
+
.withProject(Project.new('Ruby Reporting', '0.1'))
|
25
|
+
.withJob(Job.new('Ruby Job' , 1))
|
26
|
+
.withContextTags('Context tag1', 'Context tag2', 'Context tag 3' ...... )
|
27
|
+
.withWebDriver(@driver)
|
28
|
+
.build)
|
29
|
+
|
30
|
+
@reporting_client = PerfectoReportiumClient.new(perfectoExecutionContext)
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Test start command:
|
35
|
+
```Ruby
|
36
|
+
@reporting_client.testStart(self.name, TestContext.new('Test tag 1', 'Test tag 2', 'Test tag 13' ...... ))
|
37
|
+
```
|
38
|
+
|
39
|
+
Test step command:
|
40
|
+
```Ruby
|
41
|
+
@reporting_client.testStep('Test step description')
|
42
|
+
```
|
43
|
+
|
44
|
+
Test stop command:<br/>
|
45
|
+
**Note!** - in this case i'm using test instance in order to determine test condition (passed / failed)
|
46
|
+
```Ruby
|
47
|
+
if self.passed?
|
48
|
+
@reporting_client.testStop(TestResultSuccess.new)
|
49
|
+
else
|
50
|
+
@reporting_client.testStop(TestResultFailure.new(@exception.message, @exception))
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
**Running the tests:**
|
55
|
+
test_setup.rb - this file define the test behavior (setup,teardown ...)<br/>
|
56
|
+
test.rb - this is the test class inherent from PerfectoTestingBox which is in test_setup.rb file.
|
57
|
+
|
58
|
+
```
|
59
|
+
ruby test.rb
|
60
|
+
```
|
61
|
+
|
62
|
+
## Troubleshoot for windows certification error (OpenSSL::SSL::SSLError)
|
63
|
+
|
64
|
+
Download *cacert.pem* file from [here](https://curl.haxx.se/ca/cacert.pem) .
|
65
|
+
set enviorment variable using the following command in the command line: <br/>
|
66
|
+
`set SSL_CERT_FILE=PATH_OF_FILE\cacert.pem`
|
67
|
+
|
68
|
+
Note! Do not delete this file, it's required for certification.
|
data/lib/perfecto-reporting.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
# perfecto-reporting Gem
|
2
|
-
#
|
3
|
-
# For more information about the gem read the documentation file.
|
4
|
-
# For support check out our community at : www.community.perfectomobile.com
|
5
|
-
#
|
6
|
-
# MIT License
|
7
|
-
|
8
|
-
# Client classes
|
9
|
-
require_relative './perfecto-reporting/client/PerfectoReportiumClient'
|
10
|
-
require_relative './perfecto-reporting/client/ReportiumClientFactory'
|
11
|
-
|
12
|
-
# Model classes
|
13
|
-
require_relative 'perfecto-reporting/model/PerfectoExecutionContext'
|
14
|
-
require_relative 'perfecto-reporting/model/Job'
|
15
|
-
require_relative 'perfecto-reporting/model/Project'
|
16
|
-
require_relative 'perfecto-reporting/model/CustomField'
|
17
|
-
|
18
|
-
# Test classes
|
19
|
-
require_relative 'perfecto-reporting/test/TestContext'
|
20
|
-
require_relative 'perfecto-reporting/test/result/TestResultFactory'
|
1
|
+
# perfecto-reporting Gem
|
2
|
+
#
|
3
|
+
# For more information about the gem read the documentation file.
|
4
|
+
# For support check out our community at : www.community.perfectomobile.com
|
5
|
+
#
|
6
|
+
# MIT License
|
7
|
+
|
8
|
+
# Client classes
|
9
|
+
require_relative './perfecto-reporting/client/PerfectoReportiumClient'
|
10
|
+
require_relative './perfecto-reporting/client/ReportiumClientFactory'
|
11
|
+
|
12
|
+
# Model classes
|
13
|
+
require_relative 'perfecto-reporting/model/PerfectoExecutionContext'
|
14
|
+
require_relative 'perfecto-reporting/model/Job'
|
15
|
+
require_relative 'perfecto-reporting/model/Project'
|
16
|
+
require_relative 'perfecto-reporting/model/CustomField'
|
17
|
+
|
18
|
+
# Test classes
|
19
|
+
require_relative 'perfecto-reporting/test/TestContext'
|
20
|
+
require_relative 'perfecto-reporting/test/result/TestResultFactory'
|
@@ -1,168 +1,168 @@
|
|
1
|
-
require_relative '../model/PerfectoExecutionContext'
|
2
|
-
require_relative '../exceptions/ReportiumException'
|
3
|
-
require_relative 'constants'
|
4
|
-
|
5
|
-
# PerfectoReportiumClient
|
6
|
-
class PerfectoReportiumClient
|
7
|
-
|
8
|
-
attr_accessor :perfectoExecutionContext
|
9
|
-
|
10
|
-
def initialize(perfectoExecutionContext)
|
11
|
-
@perfectoExecutionContext = perfectoExecutionContext
|
12
|
-
end
|
13
|
-
|
14
|
-
# creates a new test execution
|
15
|
-
#
|
16
|
-
# name - test name
|
17
|
-
# context - test context instance
|
18
|
-
#
|
19
|
-
# returns - id of created test
|
20
|
-
def testStart(name, context)
|
21
|
-
params = {}
|
22
|
-
|
23
|
-
unless @perfectoExecutionContext.job.nil?
|
24
|
-
params['jobName'] = @perfectoExecutionContext.job.name
|
25
|
-
params['jobNumber'] = @perfectoExecutionContext.job.number
|
26
|
-
params['jobBranch']= @perfectoExecutionContext.job.br_name
|
27
|
-
end
|
28
|
-
|
29
|
-
unless @perfectoExecutionContext.project.nil?
|
30
|
-
params['projectName'] = @perfectoExecutionContext.project.name
|
31
|
-
params['projectVersion'] = @perfectoExecutionContext.project.version
|
32
|
-
end
|
33
|
-
|
34
|
-
params['name'] = name
|
35
|
-
|
36
|
-
params['tags'] = @perfectoExecutionContext.contextTags
|
37
|
-
unless context.testExecutionTags.nil?
|
38
|
-
params['tags'] += context.testExecutionTags
|
39
|
-
end
|
40
|
-
|
41
|
-
# need to merge the CustomFields from the two levels of context
|
42
|
-
# the TestContext (in the "context" parameter) values overwrite the ExecutionContext
|
43
|
-
custom_flds = @perfectoExecutionContext.customFields
|
44
|
-
context.customFields.each do |key, value|
|
45
|
-
custom_flds[key] = value
|
46
|
-
end
|
47
|
-
|
48
|
-
custom_json = custom_flds.map { |key, value| key + '=' + value }
|
49
|
-
# the format that script wants is: '[ "test=sample","tester=new_tester"]'
|
50
|
-
params['customFields'] = custom_json
|
51
|
-
|
52
|
-
executeScript($START_TEST_COMMAND, params)
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
# logging a logical test step.
|
57
|
-
#
|
58
|
-
# ### DEPRECATED ###
|
59
|
-
#
|
60
|
-
# description - step description, will be presented on reporting ui.
|
61
|
-
#
|
62
|
-
# returns - id of created step
|
63
|
-
#
|
64
|
-
# e.g. 'click on next button'
|
65
|
-
def testStep(description)
|
66
|
-
warn 'testStep method is deprecated, please use stepStart or stepEnd commands instead.'
|
67
|
-
executeScript($START_STEP_COMMAND, {:name => description})
|
68
|
-
end
|
69
|
-
|
70
|
-
# logging a logical test step start
|
71
|
-
#
|
72
|
-
# description - step description
|
73
|
-
def stepStart(description)
|
74
|
-
executeScript($START_STEP_COMMAND, {:name => description})
|
75
|
-
end
|
76
|
-
|
77
|
-
# logging a logical test step end
|
78
|
-
#
|
79
|
-
# message - a possible message to attach
|
80
|
-
def stepEnd(message=nil)
|
81
|
-
executeScript($END_STEP_COMMAND, {:message => message})
|
82
|
-
end
|
83
|
-
|
84
|
-
# Indicates that the test has stopped and its execution status.
|
85
|
-
#
|
86
|
-
# testResult - testResult instance
|
87
|
-
#
|
88
|
-
# returns - false if the method failed due to existing conditions such as a previous call to testStart that failed,
|
89
|
-
# otherwise return true
|
90
|
-
def testStop(testResult)
|
91
|
-
|
92
|
-
params = {
|
93
|
-
:success => testResult.isSuccessful
|
94
|
-
}
|
95
|
-
|
96
|
-
if !testResult.isSuccessful
|
97
|
-
params['failureDescription'] = testResult.message
|
98
|
-
params['failureReason'] = testResult.failureReason
|
99
|
-
end
|
100
|
-
|
101
|
-
executeScript($END_TEST_COMMAND, params)
|
102
|
-
return true
|
103
|
-
end
|
104
|
-
|
105
|
-
def testStop(testResult, context)
|
106
|
-
|
107
|
-
params = {
|
108
|
-
:success => testResult.isSuccessful
|
109
|
-
}
|
110
|
-
|
111
|
-
if !testResult.isSuccessful
|
112
|
-
params['failureDescription'] = testResult.message
|
113
|
-
params['failureReason'] = testResult.failureReason
|
114
|
-
end
|
115
|
-
|
116
|
-
unless context.testExecutionTags.nil?
|
117
|
-
params['tags'] = context.testExecutionTags
|
118
|
-
end
|
119
|
-
|
120
|
-
custom_json = context.customFields.map { |key, value| key + '=' + value }
|
121
|
-
# the format that script wants is: '[ "test=sample","tester=new_tester"]'
|
122
|
-
params['customFields'] = custom_json
|
123
|
-
|
124
|
-
executeScript($END_TEST_COMMAND, params)
|
125
|
-
return true
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
|
-
# log a new assertion
|
130
|
-
#
|
131
|
-
# message - a message to be attached to the assertion
|
132
|
-
# status - true / false value
|
133
|
-
def reportiumAssert(message, status)
|
134
|
-
params = {
|
135
|
-
:message => message,
|
136
|
-
:status => status
|
137
|
-
}
|
138
|
-
executeScript($ASSERT_COMMAND, params)
|
139
|
-
end
|
140
|
-
|
141
|
-
# Returns the URL to the created online report in Perfecto's reporting solution.
|
142
|
-
#
|
143
|
-
# name - test name
|
144
|
-
# The report is based on all tests that match the current execution context, and is not
|
145
|
-
# limited to a single functional test execution.
|
146
|
-
#
|
147
|
-
# returns - URL to the created online report
|
148
|
-
#
|
149
|
-
# raise exception if driver has no capabilities variable
|
150
|
-
def getReportUrl()
|
151
|
-
url = nil
|
152
|
-
webdriver = @perfectoExecutionContext.webdriver
|
153
|
-
|
154
|
-
begin
|
155
|
-
url = webdriver.capabilities['testGridReportUrl']
|
156
|
-
rescue Exception => e
|
157
|
-
raise ReportiumException.new e.message
|
158
|
-
end
|
159
|
-
|
160
|
-
return url
|
161
|
-
end
|
162
|
-
|
163
|
-
def executeScript(script, params)
|
164
|
-
webdriver = @perfectoExecutionContext.webdriver
|
165
|
-
return webdriver.execute_script(script, params)
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|
1
|
+
require_relative '../model/PerfectoExecutionContext'
|
2
|
+
require_relative '../exceptions/ReportiumException'
|
3
|
+
require_relative 'constants'
|
4
|
+
|
5
|
+
# PerfectoReportiumClient
|
6
|
+
class PerfectoReportiumClient
|
7
|
+
|
8
|
+
attr_accessor :perfectoExecutionContext
|
9
|
+
|
10
|
+
def initialize(perfectoExecutionContext)
|
11
|
+
@perfectoExecutionContext = perfectoExecutionContext
|
12
|
+
end
|
13
|
+
|
14
|
+
# creates a new test execution
|
15
|
+
#
|
16
|
+
# name - test name
|
17
|
+
# context - test context instance
|
18
|
+
#
|
19
|
+
# returns - id of created test
|
20
|
+
def testStart(name, context)
|
21
|
+
params = {}
|
22
|
+
|
23
|
+
unless @perfectoExecutionContext.job.nil?
|
24
|
+
params['jobName'] = @perfectoExecutionContext.job.name
|
25
|
+
params['jobNumber'] = @perfectoExecutionContext.job.number
|
26
|
+
params['jobBranch']= @perfectoExecutionContext.job.br_name
|
27
|
+
end
|
28
|
+
|
29
|
+
unless @perfectoExecutionContext.project.nil?
|
30
|
+
params['projectName'] = @perfectoExecutionContext.project.name
|
31
|
+
params['projectVersion'] = @perfectoExecutionContext.project.version
|
32
|
+
end
|
33
|
+
|
34
|
+
params['name'] = name
|
35
|
+
|
36
|
+
params['tags'] = @perfectoExecutionContext.contextTags
|
37
|
+
unless context.testExecutionTags.nil?
|
38
|
+
params['tags'] += context.testExecutionTags
|
39
|
+
end
|
40
|
+
|
41
|
+
# need to merge the CustomFields from the two levels of context
|
42
|
+
# the TestContext (in the "context" parameter) values overwrite the ExecutionContext
|
43
|
+
custom_flds = @perfectoExecutionContext.customFields
|
44
|
+
context.customFields.each do |key, value|
|
45
|
+
custom_flds[key] = value
|
46
|
+
end
|
47
|
+
|
48
|
+
custom_json = custom_flds.map { |key, value| key + '=' + value }
|
49
|
+
# the format that script wants is: '[ "test=sample","tester=new_tester"]'
|
50
|
+
params['customFields'] = custom_json
|
51
|
+
|
52
|
+
executeScript($START_TEST_COMMAND, params)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
# logging a logical test step.
|
57
|
+
#
|
58
|
+
# ### DEPRECATED ###
|
59
|
+
#
|
60
|
+
# description - step description, will be presented on reporting ui.
|
61
|
+
#
|
62
|
+
# returns - id of created step
|
63
|
+
#
|
64
|
+
# e.g. 'click on next button'
|
65
|
+
def testStep(description)
|
66
|
+
warn 'testStep method is deprecated, please use stepStart or stepEnd commands instead.'
|
67
|
+
executeScript($START_STEP_COMMAND, {:name => description})
|
68
|
+
end
|
69
|
+
|
70
|
+
# logging a logical test step start
|
71
|
+
#
|
72
|
+
# description - step description
|
73
|
+
def stepStart(description)
|
74
|
+
executeScript($START_STEP_COMMAND, {:name => description})
|
75
|
+
end
|
76
|
+
|
77
|
+
# logging a logical test step end
|
78
|
+
#
|
79
|
+
# message - a possible message to attach
|
80
|
+
def stepEnd(message=nil)
|
81
|
+
executeScript($END_STEP_COMMAND, {:message => message})
|
82
|
+
end
|
83
|
+
|
84
|
+
# Indicates that the test has stopped and its execution status.
|
85
|
+
#
|
86
|
+
# testResult - testResult instance
|
87
|
+
#
|
88
|
+
# returns - false if the method failed due to existing conditions such as a previous call to testStart that failed,
|
89
|
+
# otherwise return true
|
90
|
+
def testStop(testResult)
|
91
|
+
|
92
|
+
params = {
|
93
|
+
:success => testResult.isSuccessful
|
94
|
+
}
|
95
|
+
|
96
|
+
if !testResult.isSuccessful
|
97
|
+
params['failureDescription'] = testResult.message
|
98
|
+
params['failureReason'] = testResult.failureReason
|
99
|
+
end
|
100
|
+
|
101
|
+
executeScript($END_TEST_COMMAND, params)
|
102
|
+
return true
|
103
|
+
end
|
104
|
+
|
105
|
+
def testStop(testResult, context)
|
106
|
+
|
107
|
+
params = {
|
108
|
+
:success => testResult.isSuccessful
|
109
|
+
}
|
110
|
+
|
111
|
+
if !testResult.isSuccessful
|
112
|
+
params['failureDescription'] = testResult.message
|
113
|
+
params['failureReason'] = testResult.failureReason
|
114
|
+
end
|
115
|
+
|
116
|
+
unless context.testExecutionTags.nil?
|
117
|
+
params['tags'] = context.testExecutionTags
|
118
|
+
end
|
119
|
+
|
120
|
+
custom_json = context.customFields.map { |key, value| key + '=' + value }
|
121
|
+
# the format that script wants is: '[ "test=sample","tester=new_tester"]'
|
122
|
+
params['customFields'] = custom_json
|
123
|
+
|
124
|
+
executeScript($END_TEST_COMMAND, params)
|
125
|
+
return true
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
# log a new assertion
|
130
|
+
#
|
131
|
+
# message - a message to be attached to the assertion
|
132
|
+
# status - true / false value
|
133
|
+
def reportiumAssert(message, status)
|
134
|
+
params = {
|
135
|
+
:message => message,
|
136
|
+
:status => status
|
137
|
+
}
|
138
|
+
executeScript($ASSERT_COMMAND, params)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns the URL to the created online report in Perfecto's reporting solution.
|
142
|
+
#
|
143
|
+
# name - test name
|
144
|
+
# The report is based on all tests that match the current execution context, and is not
|
145
|
+
# limited to a single functional test execution.
|
146
|
+
#
|
147
|
+
# returns - URL to the created online report
|
148
|
+
#
|
149
|
+
# raise exception if driver has no capabilities variable
|
150
|
+
def getReportUrl()
|
151
|
+
url = nil
|
152
|
+
webdriver = @perfectoExecutionContext.webdriver
|
153
|
+
|
154
|
+
begin
|
155
|
+
url = webdriver.capabilities['testGridReportUrl']
|
156
|
+
rescue Exception => e
|
157
|
+
raise ReportiumException.new e.message
|
158
|
+
end
|
159
|
+
|
160
|
+
return url
|
161
|
+
end
|
162
|
+
|
163
|
+
def executeScript(script, params)
|
164
|
+
webdriver = @perfectoExecutionContext.webdriver
|
165
|
+
return webdriver.execute_script(script, params)
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|