Class: ElasticResults::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_results/result.rb

Overview

A common data format for test results. The Cucumber and Rspec formatters populate this class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#build_numberObject

Returns the value of attribute build_number.



8
9
10
# File 'lib/elastic_results/result.rb', line 8

def build_number
  @build_number
end

#exception_classObject

Returns the value of attribute exception_class.



7
8
9
# File 'lib/elastic_results/result.rb', line 7

def exception_class
  @exception_class
end

#exception_msgObject

Returns the value of attribute exception_msg.



7
8
9
# File 'lib/elastic_results/result.rb', line 7

def exception_msg
  @exception_msg
end

#exception_stacktraceObject

Returns the value of attribute exception_stacktrace.



7
8
9
# File 'lib/elastic_results/result.rb', line 7

def exception_stacktrace
  @exception_stacktrace
end

#feature_nameObject

Returns the value of attribute feature_name.



8
9
10
# File 'lib/elastic_results/result.rb', line 8

def feature_name
  @feature_name
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/elastic_results/result.rb', line 8

def id
  @id
end

#outcomeObject

Returns the value of attribute outcome.



7
8
9
# File 'lib/elastic_results/result.rb', line 7

def outcome
  @outcome
end

#runtimeObject

Returns the value of attribute runtime.



7
8
9
# File 'lib/elastic_results/result.rb', line 7

def runtime
  @runtime
end

#scenario_nameObject

Returns the value of attribute scenario_name.



8
9
10
# File 'lib/elastic_results/result.rb', line 8

def scenario_name
  @scenario_name
end

#uriObject

Returns the value of attribute uri.



8
9
10
# File 'lib/elastic_results/result.rb', line 8

def uri
  @uri
end

Instance Method Details

#base_infoObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/elastic_results/result.rb', line 32

def base_info
  {
    '@timestamp' => Time.now.iso8601(3),
    build_number: ENV['BUILD_NUMBER'] ? ENV['BUILD_NUMBER'] : ElasticResults.build_id,
    build_url: ENV['BUILD_URL'],
    node_name: ENV['NODE_NAME'] ? ENV['NODE_NAME'] : Socket.gethostname,
    job_name: ENV['JOB_NAME'],
    build_tag: ENV['BUILD_TAG'],
    environment: ENV['TEST_ENV'] || ENV['RAILS_ENV'],
    git_commit: ElasticResults.git_commit,
    git_url: ElasticResults.git_url,
    git_branch: ElasticResults.git_branch,
    suite_name: ElasticResults.suite_name,
    suite_type: ElasticResults.suite_type,
    team: ElasticResults.team_name
  }
end

#fail_typeObject



28
29
30
# File 'lib/elastic_results/result.rb', line 28

def fail_type
  exception_class =~ /ExpectationNotMet/ ? :fail : :broke
end

#tagsObject



20
21
22
# File 'lib/elastic_results/result.rb', line 20

def tags
  @tags ||= []
end

#to_hashObject



10
11
12
13
14
15
16
17
18
# File 'lib/elastic_results/result.rb', line 10

def to_hash
  result_hash = base_info

  [:outcome, :exception_class, :exception_msg, :exception_stacktrace, :runtime,
   :id, :uri, :feature_name, :scenario_name, :tags].each do |field|
    result_hash[field] = send field
  end
  result_hash
end