Method: TestCase#initialize

Defined in:
lib/test_case/test_case.rb

#initialize(id, device_ids, iteration, host, job, log_file, log_level, data: nil, auth: nil, workspace: nil) ⇒ TestCase

Public: Initializes a new TestCase. NOT FOR USE IN TESTS.

Returns nothing.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/test_case/test_case.rb', line 86

def initialize(id, device_ids, iteration, host, job, log_file, log_level, data: nil, auth: nil, workspace: nil)
  super(nil)
  @status = TestStatus.new(self, nil)
  # Set attributes from parameters

  @id = id
  @device_ids = device_ids || [] # needed for syntax eval

  @primary_device_id = @device_ids.empty? ? nil : @device_ids.first
  @identity = job
  @iteration = iteration
  @host = host
  @job = job
  @workspace = workspace
  # Set remaining attributes

  @type = nil
  @start_time = nil
  @stop_time = nil
  @teardowns = []
  @steps = []
  @errors = []
  @current_step = nil
  @data = nil
  @duts = {}
  @loaded_libs = false
  @recording_video_id = nil
  @video_recording_ids = {}
  @audio_recording_ids = {}
  @locked_resources = {}
  @reported_results = false
  @test_steps_ignore_errors = false
  @ignore_errors = false
  @no_log_trace = false
  # Set these attributes last as they may depend on others

  # Create base logger

  base_logger = TmcLogger.new(log_file, log_level)
  @loggers = {}
  if device?
    # Create DUT logger for each device

    @device_ids.each_with_index do |d, i|
      @loggers[d] = TmcDutLogger.new(i + 1, base_logger, self)
    end
  else
    # Create a non-device logger

    @loggers[0] = TmcDutLogger.new(nil, base_logger, self)
  end
  @logger = @loggers.values.first
  @test_data = TestData.new(self, job: @job, data: data)
  @ssh = TmcSsh.new(self)
  # Anything that logs should go here

  unless auth.nil?
    # Log in using base-64 auth

    resp = tmc_post('/api/login', json: { value: auth })
    @identity = resp['guid']
  end
  @ignore_interrupt = false
  @canceled = false
  trap_signals
end