Class: PerfectoReportiumClient

Inherits:
Object
  • Object
show all
Defined in:
lib/perfecto-reporting/client/PerfectoReportiumClient.rb

Overview

PerfectoReportiumClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(perfectoExecutionContext) ⇒ PerfectoReportiumClient

Returns a new instance of PerfectoReportiumClient.



10
11
12
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 10

def initialize(perfectoExecutionContext)
  @perfectoExecutionContext = perfectoExecutionContext
end

Instance Attribute Details

#perfectoExecutionContextObject

Returns the value of attribute perfectoExecutionContext.



8
9
10
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 8

def perfectoExecutionContext
  @perfectoExecutionContext
end

Instance Method Details

#executeScript(script, params) ⇒ Object



163
164
165
166
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 163

def executeScript(script, params)
  webdriver = @perfectoExecutionContext.webdriver
  return webdriver.execute_script(script, params)
end

#getReportUrlObject

Returns the URL to the created online report in Perfecto’s reporting solution.

name - test name The report is based on all tests that match the current execution context, and is not limited to a single functional test execution.

returns - URL to the created online report

raise exception if driver has no capabilities variable



150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 150

def getReportUrl()
  url = nil
  webdriver = @perfectoExecutionContext.webdriver

  begin
    url = webdriver.capabilities['testGridReportUrl']
  rescue Exception => e
    raise ReportiumException.new e.message
  end

  return url
end

#reportiumAssert(message, status) ⇒ Object

log a new assertion

message - a message to be attached to the assertion status - true / false value



133
134
135
136
137
138
139
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 133

def reportiumAssert(message, status)
  params = {
      :message => message,
      :status => status
  }
  executeScript($ASSERT_COMMAND, params)
end

#stepEnd(message = nil) ⇒ Object

logging a logical test step end

message - a possible message to attach



80
81
82
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 80

def stepEnd(message=nil)
  executeScript($END_STEP_COMMAND, {:message => message})
end

#stepStart(description) ⇒ Object

logging a logical test step start

description - step description



73
74
75
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 73

def stepStart(description)
  executeScript($START_STEP_COMMAND, {:name => description})
end

#testStart(name, context) ⇒ Object

creates a new test execution

name - test name context - test context instance

returns - id of created test



20
21
22
23
24
25
26
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
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 20

def testStart(name, context)
  params = {}

  unless @perfectoExecutionContext.job.nil?
    params['jobName'] = @perfectoExecutionContext.job.name
    params['jobNumber'] = @perfectoExecutionContext.job.number
 params['jobBranch']= @perfectoExecutionContext.job.br_name
  end

  unless @perfectoExecutionContext.project.nil?
    params['projectName'] = @perfectoExecutionContext.project.name
    params['projectVersion'] = @perfectoExecutionContext.project.version
  end

  params['name'] = name
	
  params['tags'] = @perfectoExecutionContext.contextTags
  unless context.testExecutionTags.nil?
params['tags'] += context.testExecutionTags
  end
 
	# need to merge the CustomFields from the two levels of context
	# the TestContext (in the "context" parameter) values overwrite the ExecutionContext
  custom_flds = @perfectoExecutionContext.customFields
  context.customFields.each do |key, value|
	custom_flds[key] = value
  end
	
  custom_json = custom_flds.map { |key, value| key + '=' + value }
  # the format that script wants is: '[ "test=sample","tester=new_tester"]'
  params['customFields'] = custom_json

  executeScript($START_TEST_COMMAND, params)
end

#testStep(description) ⇒ Object

logging a logical test step.

### DEPRECATED ###

description - step description, will be presented on reporting ui.

returns - id of created step

e.g. ‘click on next button’



65
66
67
68
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 65

def testStep(description)
  warn 'testStep method is deprecated, please use stepStart or stepEnd commands instead.'
  executeScript($START_STEP_COMMAND, {:name => description})
end

#testStop(testResult, context) ⇒ Object

Indicates that the test has stopped and its execution status.

testResult - testResult instance

returns - false if the method failed due to existing conditions such as a previous call to testStart that failed, otherwise return true



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/perfecto-reporting/client/PerfectoReportiumClient.rb', line 90

def testStop(testResult)

  params = {
      :success => testResult.isSuccessful
  }

  if !testResult.isSuccessful
    params['failureDescription'] = testResult.message
    params['failureReason'] = testResult.failureReason
  end

  executeScript($END_TEST_COMMAND, params)
  return true
end