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.



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

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.



5
6
7
# File 'lib/applitools/core/test_results.rb', line 5

def is_new
  @is_new
end

#matchesObject (readonly)

Returns the value of attribute matches.



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

def matches
  @matches
end

#mismatchesObject (readonly)

Returns the value of attribute mismatches.



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

def mismatches
  @mismatches
end

#missingObject (readonly)

Returns the value of attribute missing.



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

def missing
  @missing
end

#original_resultsObject (readonly)

Returns the value of attribute original_results.



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

def original_results
  @original_results
end

#screenshotObject

Returns the value of attribute screenshot.



5
6
7
# File 'lib/applitools/core/test_results.rb', line 5

def screenshot
  @screenshot
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/applitools/core/test_results.rb', line 5

def url
  @url
end

Instance Method Details

#==(other) ⇒ Object



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

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)


39
40
41
# File 'lib/applitools/core/test_results.rb', line 39

def aborted?
  original_results['isAborted']
end

#different?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/applitools/core/test_results.rb', line 35

def different?
  original_results['isDifferent']
end

#failed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/applitools/core/test_results.rb', line 23

def failed?
  status == 'Failed'
end

#new?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/applitools/core/test_results.rb', line 31

def new?
  original_results['isNew']
end

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/applitools/core/test_results.rb', line 19

def passed?
  status == 'Passed'
end

#to_s(advanced = false) ⇒ Object



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

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)


27
28
29
# File 'lib/applitools/core/test_results.rb', line 27

def unresolved?
  status == 'Unresolved'
end