perfecto-reporting 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/perfecto-reporting.rb +18 -0
- data/lib/perfecto-reporting/client/PerfectoReportiumClient.rb +111 -0
- data/lib/perfecto-reporting/exceptions/ReportiumException.rb +12 -0
- data/lib/perfecto-reporting/model/Job.rb +16 -0
- data/lib/perfecto-reporting/model/PerfectoExecutionContext.rb +95 -0
- data/lib/perfecto-reporting/model/Project.rb +18 -0
- data/lib/perfecto-reporting/test/TestContext.rb +14 -0
- data/lib/perfecto-reporting/test/result/TestResult.rb +14 -0
- data/lib/perfecto-reporting/test/result/TestResultFactory.rb +26 -0
- data/lib/perfecto-reporting/test/result/TestResultFailure.rb +32 -0
- data/lib/perfecto-reporting/test/result/TestResultSuccess.rb +18 -0
- data/lib/perfecto-reporting/version.rb +7 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a8d8e76e6f37480eee7f5300238d7b60249d20b
|
4
|
+
data.tar.gz: 7bec1c7b3b3c8f29ad827427d91513e05292ef85
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c711244a1a30c4ed13311ba801c46dca95d8b64453c4b26c344126bf4fd2a0df70a3f5e18964b2137e21d8852b9020328cfefbb8e70b2473a7ee8f93cdebf5e
|
7
|
+
data.tar.gz: 1828afc5cc6990974260f51e4b2584760b6eb01180ffd97626cd0b08ef9e24e7e6452a27f1f639a181e702b6140200255021cc2ee84c9208b20e3971640b817a
|
@@ -0,0 +1,18 @@
|
|
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 'perfecto-reporting/client/PerfectoReportiumClient'
|
10
|
+
|
11
|
+
# Model classes
|
12
|
+
require 'perfecto-reporting/model/PerfectoExecutionContext'
|
13
|
+
require 'perfecto-reporting/model/Job'
|
14
|
+
require 'perfecto-reporting/model/Project'
|
15
|
+
|
16
|
+
# Test classes
|
17
|
+
require 'perfecto-reporting/test/TestContext'
|
18
|
+
require 'perfecto-reporting/test/result/TestResultFactory'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
require_relative '../model/PerfectoExecutionContext'
|
3
|
+
require_relative '../exceptions/ReportiumException'
|
4
|
+
|
5
|
+
# PerfectoReportiumClient
|
6
|
+
class PerfectoReportiumClient
|
7
|
+
|
8
|
+
# Test Commands
|
9
|
+
START_TEST_COMMAND = 'mobile:test:start';
|
10
|
+
TEST_STEP_COMMAND = 'mobile:test:step';
|
11
|
+
END_TEST_COMMAND = 'mobile:test:end';
|
12
|
+
|
13
|
+
attr_accessor :currentTestId, :perfectoExecutionContext
|
14
|
+
|
15
|
+
def initialize(perfectoExecutionContext)
|
16
|
+
@perfectoExecutionContext = perfectoExecutionContext
|
17
|
+
end
|
18
|
+
|
19
|
+
# creates a new test execution
|
20
|
+
#
|
21
|
+
# name - test name
|
22
|
+
# context - test context instance
|
23
|
+
#
|
24
|
+
# returns - id of created test
|
25
|
+
def testStart(name, context)
|
26
|
+
params = {}
|
27
|
+
|
28
|
+
unless @perfectoExecutionContext.job.nil?
|
29
|
+
params['jobName'] = @perfectoExecutionContext.job.name
|
30
|
+
params['jobNumber'] = @perfectoExecutionContext.job.number
|
31
|
+
end
|
32
|
+
|
33
|
+
unless @perfectoExecutionContext.project.nil?
|
34
|
+
params['projectName'] = @perfectoExecutionContext.job.name
|
35
|
+
params['projectVersion'] = @perfectoExecutionContext.project.version
|
36
|
+
end
|
37
|
+
|
38
|
+
params['name'] = name
|
39
|
+
params['tags'] = @perfectoExecutionContext.contextTags + context.testExecutionTags
|
40
|
+
|
41
|
+
@currentTestId = executeScript(START_TEST_COMMAND, params)
|
42
|
+
return @currentTestId
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# logging a logical test step.
|
48
|
+
#
|
49
|
+
# description - step description, will be presented on reporting ui.
|
50
|
+
#
|
51
|
+
# returns - id of created step
|
52
|
+
#
|
53
|
+
# e.g. 'click on next button'
|
54
|
+
def testStep(description)
|
55
|
+
params = {:name => description}
|
56
|
+
return executeScript(TEST_STEP_COMMAND, params)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# Indicates that the test has stopped and its execution status.
|
61
|
+
#
|
62
|
+
# testResult - testResult instance
|
63
|
+
#
|
64
|
+
# returns - false if the method failed due to existing conditions such as a previous call to testStart that failed,
|
65
|
+
# otherwise return true
|
66
|
+
def testStop(testResult)
|
67
|
+
if @currentTestId.to_s == ''
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
71
|
+
params = {
|
72
|
+
:success => testResult.isSuccessful
|
73
|
+
}
|
74
|
+
|
75
|
+
if !testResult.isSuccessful
|
76
|
+
params['failureDescription'] = testResult.message
|
77
|
+
end
|
78
|
+
|
79
|
+
executeScript(END_TEST_COMMAND, params)
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# Returns the URL to the created online report in Perfecto's reporting solution.
|
85
|
+
#
|
86
|
+
# name - test name
|
87
|
+
# The report is based on all tests that match the current execution context, and is not
|
88
|
+
# limited to a single functional test execution.
|
89
|
+
#
|
90
|
+
# returns - URL to the created online report
|
91
|
+
#
|
92
|
+
# raise exception if driver has no capabilities variable
|
93
|
+
def getReportUrl()
|
94
|
+
url = nil
|
95
|
+
webdriver = @perfectoExecutionContext.webdriver
|
96
|
+
|
97
|
+
begin
|
98
|
+
url = webdriver.capabilities['testGridReportUrl']
|
99
|
+
rescue Exception => e
|
100
|
+
raise ReportiumException.new e.message
|
101
|
+
end
|
102
|
+
|
103
|
+
return url
|
104
|
+
end
|
105
|
+
|
106
|
+
def executeScript(script, params)
|
107
|
+
webdriver = @perfectoExecutionContext.webdriver
|
108
|
+
return webdriver.execute_script(script, params)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
# Job
|
3
|
+
# Defines a job which runs the test / group of tests
|
4
|
+
#
|
5
|
+
# This can be used in order to locate specific job in reporting ui
|
6
|
+
class Job
|
7
|
+
|
8
|
+
attr_accessor :name, :number
|
9
|
+
|
10
|
+
# initialize a new job instance
|
11
|
+
def initialize name, number
|
12
|
+
@name = name
|
13
|
+
@number = number
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require_relative '../exceptions/ReportiumException'
|
2
|
+
|
3
|
+
# PerfectoExecutionContext
|
4
|
+
#
|
5
|
+
# This class define execution for MCM-based clients.
|
6
|
+
#
|
7
|
+
# Creating instance of this class possible only with PerfectoExecutionContextBuilder instance.
|
8
|
+
class PerfectoExecutionContext
|
9
|
+
|
10
|
+
attr_accessor :job, :project, :webdriver, :contextTags
|
11
|
+
|
12
|
+
# create new instance
|
13
|
+
#
|
14
|
+
# perfectoExecutionContextBuilder -
|
15
|
+
# raise ReportiumException if driver not given.
|
16
|
+
def initialize (perfectoExecutionContextBuilder)
|
17
|
+
|
18
|
+
# execution is not possible without webdriver.
|
19
|
+
if perfectoExecutionContextBuilder.webdriver.nil?
|
20
|
+
raise ReportiumException.new('Missing required webdriver argument.')
|
21
|
+
end
|
22
|
+
|
23
|
+
@job = perfectoExecutionContextBuilder.job
|
24
|
+
@project = perfectoExecutionContextBuilder.project
|
25
|
+
@webdriver = perfectoExecutionContextBuilder.webdriver
|
26
|
+
@contextTags = perfectoExecutionContextBuilder.contextTags
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# PerfectoExecutionContext
|
31
|
+
#
|
32
|
+
# This class used to create PerfectoExecutionContext instance
|
33
|
+
#
|
34
|
+
# example:
|
35
|
+
# perfectoExecutionContext::perfectoExecutionContextBuilder
|
36
|
+
# .withJob("job name" , job number )
|
37
|
+
# .withProject("project name" , project version)
|
38
|
+
# .withWebDriver(driver)
|
39
|
+
# .build()
|
40
|
+
class PerfectoExecutionContextBuilder
|
41
|
+
|
42
|
+
@@job = nil
|
43
|
+
@@project = nil
|
44
|
+
@@webdriver = nil
|
45
|
+
@@contextTags = nil
|
46
|
+
|
47
|
+
# define a job
|
48
|
+
def self.withJob job
|
49
|
+
@@job = job
|
50
|
+
return self
|
51
|
+
end
|
52
|
+
|
53
|
+
# define a project
|
54
|
+
def self.withProject project
|
55
|
+
@@project = project
|
56
|
+
return self
|
57
|
+
end
|
58
|
+
|
59
|
+
# define webdriver
|
60
|
+
def self.withWebDriver webdriver
|
61
|
+
@@webdriver = webdriver
|
62
|
+
return self
|
63
|
+
end
|
64
|
+
|
65
|
+
# define contextTags
|
66
|
+
def self.withContextTags *args
|
67
|
+
@@contextTags = args
|
68
|
+
return self
|
69
|
+
end
|
70
|
+
|
71
|
+
# building a new builder instance
|
72
|
+
def self.build
|
73
|
+
return self.new
|
74
|
+
end
|
75
|
+
|
76
|
+
def job
|
77
|
+
@@job
|
78
|
+
end
|
79
|
+
|
80
|
+
def project
|
81
|
+
@@project
|
82
|
+
end
|
83
|
+
|
84
|
+
def contextTags
|
85
|
+
@@contextTags
|
86
|
+
end
|
87
|
+
|
88
|
+
def webdriver
|
89
|
+
@@webdriver
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Project
|
2
|
+
# This class defines a Project
|
3
|
+
#
|
4
|
+
# Tests with same projects can be filtered within reporting ui.
|
5
|
+
class Project
|
6
|
+
|
7
|
+
attr_accessor :name, :version
|
8
|
+
|
9
|
+
# initialize new project instance
|
10
|
+
#
|
11
|
+
# name - the new project's name
|
12
|
+
# version - the project's version
|
13
|
+
def initialize name, version
|
14
|
+
@name = name
|
15
|
+
@version = version
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# TestContext
|
2
|
+
#
|
3
|
+
# TestContext tags will be presented in reporting ui.
|
4
|
+
# This tags attached to each test execution.
|
5
|
+
class TestContext
|
6
|
+
|
7
|
+
attr_accessor :testExecutionTags
|
8
|
+
|
9
|
+
# Create TestContext instance
|
10
|
+
def initialize *args
|
11
|
+
@testExecutionTags = args
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'TestResultSuccess'
|
2
|
+
require_relative 'TestResultFailure'
|
3
|
+
|
4
|
+
# TestResultFactory
|
5
|
+
#
|
6
|
+
# Generates a new test result instance.
|
7
|
+
class TestResultFactory
|
8
|
+
|
9
|
+
# create a successful test execution result
|
10
|
+
#
|
11
|
+
# return - instance denoting a successful test execution
|
12
|
+
def self.createSuccess
|
13
|
+
return TestResultSuccess.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# Creates a failed test execution result
|
17
|
+
#
|
18
|
+
# reason - string representation of the reason for the test failure
|
19
|
+
# error - the exception caused the failure
|
20
|
+
#
|
21
|
+
# return - instance denoting a failed test execution
|
22
|
+
def self.createFailure reason, error
|
23
|
+
return TestResultFailure.new(reason, error)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'TestResult'
|
2
|
+
|
3
|
+
# TestResultFailure
|
4
|
+
#
|
5
|
+
# Define a failure test result.
|
6
|
+
class TestResultFailure < TestResult
|
7
|
+
|
8
|
+
attr_accessor :message
|
9
|
+
|
10
|
+
@@status = 'FAILED'
|
11
|
+
|
12
|
+
# Create a new instance
|
13
|
+
#
|
14
|
+
# reason - string representation of the failure reason
|
15
|
+
# error - exception caused to the failure
|
16
|
+
def initialize(reason, error)
|
17
|
+
if error.is_a? Exception
|
18
|
+
@message = reason + '. Stack Trace:' + error.backtrace.to_s
|
19
|
+
else
|
20
|
+
@message = reason
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def isSuccessful
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
def status
|
29
|
+
@@status
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'TestResult'
|
2
|
+
|
3
|
+
# TestResultSuccess
|
4
|
+
#
|
5
|
+
# Define a successful test result
|
6
|
+
class TestResultSuccess < TestResult
|
7
|
+
|
8
|
+
@@status = 'PASSED'
|
9
|
+
|
10
|
+
def isSuccessful
|
11
|
+
return true
|
12
|
+
end
|
13
|
+
|
14
|
+
def status
|
15
|
+
@@status
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: perfecto-reporting
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- perfecto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: selenium-webdriver
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.53'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.53.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.53'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.53.0
|
33
|
+
description: reporting sdk for ruby
|
34
|
+
email: daniela@perfectomobile.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/perfecto-reporting.rb
|
40
|
+
- lib/perfecto-reporting/client/PerfectoReportiumClient.rb
|
41
|
+
- lib/perfecto-reporting/exceptions/ReportiumException.rb
|
42
|
+
- lib/perfecto-reporting/model/Job.rb
|
43
|
+
- lib/perfecto-reporting/model/PerfectoExecutionContext.rb
|
44
|
+
- lib/perfecto-reporting/model/Project.rb
|
45
|
+
- lib/perfecto-reporting/test/TestContext.rb
|
46
|
+
- lib/perfecto-reporting/test/result/TestResult.rb
|
47
|
+
- lib/perfecto-reporting/test/result/TestResultFactory.rb
|
48
|
+
- lib/perfecto-reporting/test/result/TestResultFailure.rb
|
49
|
+
- lib/perfecto-reporting/test/result/TestResultSuccess.rb
|
50
|
+
- lib/perfecto-reporting/version.rb
|
51
|
+
homepage: http://rubygems.org/gems/Perfecto-Reporting
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 2.4.5.1
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: perfecto reporting sdk
|
75
|
+
test_files: []
|