Class: Gitlab::Ci::Reports::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/test_case.rb

Constant Summary collapse

STATUS_SUCCESS =
'success'
STATUS_FAILED =
'failed'
STATUS_SKIPPED =
'skipped'
STATUS_ERROR =
'error'
STATUS_TYPES =
[STATUS_ERROR, STATUS_FAILED, STATUS_SUCCESS, STATUS_SKIPPED].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ TestCase

Returns a new instance of TestCase.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/ci/reports/test_case.rb', line 15

def initialize(params)
  @suite_name = params.fetch(:suite_name)
  @name = params.fetch(:name)
  @classname = params.fetch(:classname)
  @file = params.fetch(:file, nil)
  @execution_time = params.fetch(:execution_time).to_f
  @status = params.fetch(:status)
  @system_output = params.fetch(:system_output, nil)
  @stack_trace = params.fetch(:stack_trace, nil)
  @attachment = params.fetch(:attachment, nil)
  @job = params.fetch(:job, nil)

  @recent_failures = nil

  @key = hash_key("#{suite_name}_#{classname}_#{name}")
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def attachment
  @attachment
end

#classnameObject (readonly)

Returns the value of attribute classname.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def classname
  @classname
end

#execution_timeObject (readonly)

Returns the value of attribute execution_time.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def execution_time
  @execution_time
end

#fileObject (readonly)

Returns the value of attribute file.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def file
  @file
end

#jobObject (readonly)

Returns the value of attribute job.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def job
  @job
end

#keyObject (readonly)

Returns the value of attribute key.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def name
  @name
end

#recent_failuresObject (readonly)

Returns the value of attribute recent_failures.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def recent_failures
  @recent_failures
end

#stack_traceObject (readonly)

Returns the value of attribute stack_trace.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def stack_trace
  @stack_trace
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def status
  @status
end

#suite_nameObject (readonly)

Returns the value of attribute suite_name.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def suite_name
  @suite_name
end

#system_outputObject (readonly)

Returns the value of attribute system_output.



13
14
15
# File 'lib/gitlab/ci/reports/test_case.rb', line 13

def system_output
  @system_output
end

Instance Method Details

#attachment_urlObject



40
41
42
43
44
45
46
47
48
# File 'lib/gitlab/ci/reports/test_case.rb', line 40

def attachment_url
  return unless has_attachment?

  Rails.application.routes.url_helpers.file_project_job_artifacts_path(
    job.project,
    job.id,
    attachment
  )
end

#has_attachment?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitlab/ci/reports/test_case.rb', line 36

def has_attachment?
  attachment.present?
end

#set_recent_failures(count, base_branch) ⇒ Object



32
33
34
# File 'lib/gitlab/ci/reports/test_case.rb', line 32

def set_recent_failures(count, base_branch)
  @recent_failures = { count: count, base_branch: base_branch }
end