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
# File 'lib/gitlab/ci/reports/test_case.rb', line 15

def initialize(params)
  @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)

  @key = sanitize_key_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

#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

#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


33
34
35
36
37
38
39
40
41
# File 'lib/gitlab/ci/reports/test_case.rb', line 33

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)

29
30
31
# File 'lib/gitlab/ci/reports/test_case.rb', line 29

def has_attachment?
  attachment.present?
end