Class: Xcodeproj::XCScheme::TestAction::TestableReference

Inherits:
XMLElementWrapper show all
Defined in:
lib/xcodeproj/scheme/test_action.rb

Overview

————————————————————————-#

Defined Under Namespace

Classes: Test

Constant Summary collapse

SkippedTest =
TODO:

Remove in Xcodeproj 2

Aliased to`Test` for compatibility

Test

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(target_or_node = nil, root_project = nil) ⇒ TestableReference

Returns a new instance of TestableReference.

Parameters:

  • target_or_node (Xcodeproj::Project::Object::AbstractTarget, REXML::Element) (defaults to: nil)

    Either the Xcode target to reference, or an existing XML ‘TestableReference’ node element to reference, or nil to create an new, empty TestableReference

  • the (Xcodeproj::Project)

    root project to reference from (when nil the project of the target is used)



149
150
151
152
153
154
# File 'lib/xcodeproj/scheme/test_action.rb', line 149

def initialize(target_or_node = nil, root_project = nil)
  create_xml_element_with_fallback(target_or_node, 'TestableReference') do
    self.skipped = false
    add_buildable_reference BuildableReference.new(target_or_node, root_project) unless target_or_node.nil?
  end
end

Instance Method Details

#add_buildable_reference(ref) ⇒ Object

Parameters:

  • ref (BuildableReference)

    The BuildableReference to add to the list of targets this action will build



218
219
220
# File 'lib/xcodeproj/scheme/test_action.rb', line 218

def add_buildable_reference(ref)
  @xml_element.add_element(ref.xml_element)
end

#add_selected_test(selected_test) ⇒ Object

Parameters:

  • selected_test (Test)

    The SelectedTest to add to the list of tests this action will run.



293
294
295
296
# File 'lib/xcodeproj/scheme/test_action.rb', line 293

def add_selected_test(selected_test)
  entries = @xml_element.elements['SelectedTests'] || @xml_element.add_element('SelectedTests')
  entries.add_element(selected_test.xml_element)
end

#add_skipped_test(skipped_test) ⇒ Object

Parameters:

  • skipped_test (Test)

    The SkippedTest to add to the list of tests this action will skip



249
250
251
252
# File 'lib/xcodeproj/scheme/test_action.rb', line 249

def add_skipped_test(skipped_test)
  entries = @xml_element.elements['SkippedTests'] || @xml_element.add_element('SkippedTests')
  entries.add_element(skipped_test.xml_element)
end

#buildable_referencesArray<BuildableReference>

Returns The list of BuildableReferences this action will build. (The list usually contains only one element).

Returns:

  • (Array<BuildableReference>)

    The list of BuildableReferences this action will build. (The list usually contains only one element)



209
210
211
212
213
# File 'lib/xcodeproj/scheme/test_action.rb', line 209

def buildable_references
  @xml_element.get_elements('BuildableReference').map do |node|
    BuildableReference.new(node)
  end
end

#parallelizable=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether or not this TestableReference (test bundle) should be run in parallel or not



180
181
182
# File 'lib/xcodeproj/scheme/test_action.rb', line 180

def parallelizable=(flag)
  @xml_element.attributes['parallelizable'] = bool_to_string(flag)
end

#parallelizable?Bool

Returns Whether or not this TestableReference (test bundle) should be run in parallel or not.

Returns:

  • (Bool)

    Whether or not this TestableReference (test bundle) should be run in parallel or not



173
174
175
# File 'lib/xcodeproj/scheme/test_action.rb', line 173

def parallelizable?
  string_to_bool(@xml_element.attributes['parallelizable'])
end

#randomized?Bool

Returns Whether or not this TestableReference (test bundle) should be run in randomized order.

Returns:

  • (Bool)

    Whether or not this TestableReference (test bundle) should be run in randomized order.



201
202
203
# File 'lib/xcodeproj/scheme/test_action.rb', line 201

def randomized?
  test_execution_ordering == 'random'
end

#selected_testsArray<Test>

Returns The list of SelectedTest this action will run.

Returns:

  • (Array<Test>)

    The list of SelectedTest this action will run.



271
272
273
274
275
276
# File 'lib/xcodeproj/scheme/test_action.rb', line 271

def selected_tests
  return [] if @xml_element.elements['SelectedTests'].nil?
  @xml_element.elements['SelectedTests'].get_elements('Test').map do |node|
    Test.new(node)
  end
end

#selected_tests=(tests) ⇒ Object

Parameters:

  • tests (Array<Test>)

    Set the list of SelectedTest this action will run.



281
282
283
284
285
286
287
288
# File 'lib/xcodeproj/scheme/test_action.rb', line 281

def selected_tests=(tests)
  @xml_element.delete_element('SelectedTests')
  return if tests.nil?
  entries = @xml_element.add_element('SelectedTests')
  tests.each do |selected|
    entries.add_element(selected.xml_element)
  end
end

#skipped=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether or not this TestableReference (test bundle) should be skipped or not



166
167
168
# File 'lib/xcodeproj/scheme/test_action.rb', line 166

def skipped=(flag)
  @xml_element.attributes['skipped'] = bool_to_string(flag)
end

#skipped?Bool

Returns Whether or not this TestableReference (test bundle) should be skipped or not.

Returns:

  • (Bool)

    Whether or not this TestableReference (test bundle) should be skipped or not



159
160
161
# File 'lib/xcodeproj/scheme/test_action.rb', line 159

def skipped?
  string_to_bool(@xml_element.attributes['skipped'])
end

#skipped_testsArray<Test>

Returns The list of SkippedTest this action will skip.

Returns:

  • (Array<Test>)

    The list of SkippedTest this action will skip.



225
226
227
228
229
230
# File 'lib/xcodeproj/scheme/test_action.rb', line 225

def skipped_tests
  return [] if @xml_element.elements['SkippedTests'].nil?
  @xml_element.elements['SkippedTests'].get_elements('Test').map do |node|
    Test.new(node)
  end
end

#skipped_tests=(tests) ⇒ Object

Parameters:

  • tests (Array<Test>)

    Set the list of SkippedTest this action will skip.



235
236
237
238
239
240
241
242
243
244
# File 'lib/xcodeproj/scheme/test_action.rb', line 235

def skipped_tests=(tests)
  @xml_element.delete_element('SkippedTests')
  if tests.nil?
    return
  end
  entries = @xml_element.add_element('SkippedTests')
  tests.each do |skipped|
    entries.add_element(skipped.xml_element)
  end
end

#test_execution_orderingString

Returns The execution order for this TestableReference (test bundle).

Returns:

  • (String)

    The execution order for this TestableReference (test bundle)



187
188
189
# File 'lib/xcodeproj/scheme/test_action.rb', line 187

def test_execution_ordering
  @xml_element.attributes['testExecutionOrdering']
end

#test_execution_ordering=(order) ⇒ Object

Parameters:

  • order (String)

    Set the execution order for this TestableReference (test bundle)



194
195
196
# File 'lib/xcodeproj/scheme/test_action.rb', line 194

def test_execution_ordering=(order)
  @xml_element.attributes['testExecutionOrdering'] = order
end

#use_test_selection_whitelist=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether or not this TestableReference (test bundle) should use a whitelist or not



264
265
266
# File 'lib/xcodeproj/scheme/test_action.rb', line 264

def use_test_selection_whitelist=(flag)
  @xml_element.attributes['useTestSelectionWhitelist'] = bool_to_string(flag)
end

#use_test_selection_whitelist?Bool

Returns Whether or not this TestableReference (test bundle) should use a whitelist or not.

Returns:

  • (Bool)

    Whether or not this TestableReference (test bundle) should use a whitelist or not



257
258
259
# File 'lib/xcodeproj/scheme/test_action.rb', line 257

def use_test_selection_whitelist?
  string_to_bool(@xml_element.attributes['useTestSelectionWhitelist'])
end