Class: Applitools::TestResults

Inherits:
Object
  • Object
show all
Defined in:
lib/applitools/core/test_results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results = {}) ⇒ TestResults

Returns a new instance of TestResults.



10
11
12
13
14
15
16
17
18
19
# File 'lib/applitools/core/test_results.rb', line 10

def initialize(results = {})
  @original_results = results
  @steps = results.fetch('steps', 0)
  @matches = results.fetch('matches', 0)
  @mismatches = results.fetch('mismatches', 0)
  @missing = results.fetch('missing', 0)
  @status = results.fetch('status', 0)
  @is_new = nil
  @url = nil
end

Instance Attribute Details

#is_newObject

Returns the value of attribute is_new.



7
8
9
# File 'lib/applitools/core/test_results.rb', line 7

def is_new
  @is_new
end

#matchesObject (readonly)

Returns the value of attribute matches.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def matches
  @matches
end

#mismatchesObject (readonly)

Returns the value of attribute mismatches.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def mismatches
  @mismatches
end

#missingObject (readonly)

Returns the value of attribute missing.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def missing
  @missing
end

#original_resultsObject (readonly)

Returns the value of attribute original_results.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def original_results
  @original_results
end

#screenshotObject

Returns the value of attribute screenshot.



7
8
9
# File 'lib/applitools/core/test_results.rb', line 7

def screenshot
  @screenshot
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def status
  @status
end

#stepsObject (readonly)

Returns the value of attribute steps.



8
9
10
# File 'lib/applitools/core/test_results.rb', line 8

def steps
  @steps
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/applitools/core/test_results.rb', line 7

def url
  @url
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/applitools/core/test_results.rb', line 45

def ==(other)
  if other.is_a? self.class
    result = true
    %w(is_new url steps matches mismatches missing).each do |field|
      result &&= send(field) == other.send(field)
    end
    return result if result
  end
  false
end

#aborted?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/applitools/core/test_results.rb', line 41

def aborted?
  original_results['isAborted']
end

#different?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/applitools/core/test_results.rb', line 37

def different?
  original_results['isDifferent']
end

#failed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/applitools/core/test_results.rb', line 25

def failed?
  status == 'Failed'
end

#new?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/applitools/core/test_results.rb', line 33

def new?
  original_results['isNew']
end

#passed?Boolean Also known as: is_passed, as_expected?

Returns:

  • (Boolean)


21
22
23
# File 'lib/applitools/core/test_results.rb', line 21

def passed?
  status == 'Passed'
end

#to_s(advanced = false) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/applitools/core/test_results.rb', line 60

def to_s(advanced = false)
  is_new_str = ''
  is_new_str = is_new ? 'New test' : 'Existing test' unless is_new.nil?

  return @original_results.to_yaml if advanced

  "#{is_new_str} [ steps: #{steps}, matches: #{matches}, mismatches: #{mismatches}, missing: #{missing} ], " \
    "URL: #{url}"
end

#unresolved?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/applitools/core/test_results.rb', line 29

def unresolved?
  status == 'Unresolved'
end