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
# File 'lib/applitools/core/test_results.rb', line 8

def initialize(results = {})
  @steps = results.fetch('steps', 0)
  @matches = results.fetch('matches', 0)
  @mismatches = results.fetch('mismatches', 0)
  @missing = results.fetch('missing', 0)
  @is_new = nil
  @url = nil
  @original_results = results
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

#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



32
33
34
35
36
37
38
39
40
41
# File 'lib/applitools/core/test_results.rb', line 32

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

#failed?Boolean

Returns:

  • (Boolean)


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

def failed?
  return (mismatches > 0) || (missing > 0) unless new?
  false
end

#new?Boolean

Returns:

  • (Boolean)


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

def new?
  is_new
end

#passed?Boolean Also known as: is_passed

Returns:

  • (Boolean)


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

def passed?
  return !(mismatches > 0) && !(missing > 0) unless new?
  false
end

#to_s(advanced = false) ⇒ Object



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

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