Class: Xcodeproj::XCScheme::TestAction

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

Overview

This class wraps the TestAction node of a .xcscheme XML file

Defined Under Namespace

Classes: TestableReference

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from AbstractSchemeAction

#build_configuration, #build_configuration=

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(node = nil) ⇒ TestAction

Returns a new instance of TestAction.

Parameters:

  • node (REXML::Element) (defaults to: nil)

    The ‘TestAction’ XML node that this object will wrap. If nil, will create a default XML node to use.



12
13
14
15
16
17
18
19
20
# File 'lib/xcodeproj/scheme/test_action.rb', line 12

def initialize(node = nil)
  create_xml_element_with_fallback(node, 'TestAction') do
    @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB'
    @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB'
    @xml_element.add_element('AdditionalOptions')
    self.should_use_launch_scheme_args_env = true
    self.build_configuration = 'Debug'
  end
end

Instance Method Details

#add_macro_expansion(macro_expansion) ⇒ Object

Parameters:

  • macro_expansion (MacroExpansion)

    Add a MacroExpansion to this TestAction



99
100
101
# File 'lib/xcodeproj/scheme/test_action.rb', line 99

def add_macro_expansion(macro_expansion)
  @xml_element.add_element(macro_expansion.xml_element)
end

#add_testable(testable) ⇒ Object

Parameters:

  • testable (TestableReference)

    Add a TestableReference (test bundle) to this Test Action



82
83
84
85
# File 'lib/xcodeproj/scheme/test_action.rb', line 82

def add_testable(testable)
  testables = @xml_element.elements['Testables'] || @xml_element.add_element('Testables')
  testables.add_element(testable.xml_element)
end

#code_coverage_enabled=(flag) ⇒ Object



64
65
66
# File 'lib/xcodeproj/scheme/test_action.rb', line 64

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

#code_coverage_enabled?Bool

Returns Whether Clang Code Coverage is enabled (‘Gather coverage data’ turned ON).

Returns:

  • (Bool)

    Whether Clang Code Coverage is enabled (‘Gather coverage data’ turned ON)



57
58
59
# File 'lib/xcodeproj/scheme/test_action.rb', line 57

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

#command_line_argumentsCommandLineArguments

Returns the CommandLineArguments that will be passed at app launch

Returns:



125
126
127
# File 'lib/xcodeproj/scheme/test_action.rb', line 125

def command_line_arguments
  CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE])
end

#command_line_arguments=(arguments) ⇒ CommandLineArguments

Returns arguments Sets the CommandLineArguments that will be passed at app launch.

Returns:

  • (CommandLineArguments)

    arguments Sets the CommandLineArguments that will be passed at app launch



132
133
134
135
136
# File 'lib/xcodeproj/scheme/test_action.rb', line 132

def command_line_arguments=(arguments)
  @xml_element.delete_element(XCScheme::COMMAND_LINE_ARGS_NODE)
  @xml_element.add_element(arguments.xml_element) if arguments
  arguments
end

#disable_main_thread_checker=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether this Test Action should disable detection of UI API misuse from background threads



50
51
52
# File 'lib/xcodeproj/scheme/test_action.rb', line 50

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

#disable_main_thread_checker?Bool

Returns Whether this Test Action should disable detection of UI API misuse from background threads.

Returns:

  • (Bool)

    Whether this Test Action should disable detection of UI API misuse from background threads



42
43
44
# File 'lib/xcodeproj/scheme/test_action.rb', line 42

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

#environment_variablesEnvironmentVariables

Returns the EnvironmentVariables that will be defined at test launch

Returns:



106
107
108
# File 'lib/xcodeproj/scheme/test_action.rb', line 106

def environment_variables
  EnvironmentVariables.new(@xml_element.elements[XCScheme::VARIABLES_NODE])
end

#environment_variables=(env_vars) ⇒ EnvironmentVariables

Parameters:

  • env_vars (EnvironmentVariables, nil)

    Sets the EnvironmentVariables that will be defined at test launch

Returns:



114
115
116
117
118
# File 'lib/xcodeproj/scheme/test_action.rb', line 114

def environment_variables=(env_vars)
  @xml_element.delete_element(XCScheme::VARIABLES_NODE)
  @xml_element.add_element(env_vars.xml_element) if env_vars
  env_vars
end

#macro_expansionsArray<MacroExpansion>

Returns The list of MacroExpansion bound with this TestAction.

Returns:

  • (Array<MacroExpansion>)

    The list of MacroExpansion bound with this TestAction



90
91
92
93
94
# File 'lib/xcodeproj/scheme/test_action.rb', line 90

def macro_expansions
  @xml_element.get_elements('MacroExpansion').map do |node|
    MacroExpansion.new(node)
  end
end

#should_use_launch_scheme_args_env=(flag) ⇒ Object

Parameters:

  • flag (Bool)

    Set whether this Test Action should use the same arguments and environment variables as the Launch Action.



34
35
36
# File 'lib/xcodeproj/scheme/test_action.rb', line 34

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

#should_use_launch_scheme_args_env?Bool

Returns Whether this Test Action should use the same arguments and environment variables as the Launch Action.

Returns:

  • (Bool)

    Whether this Test Action should use the same arguments and environment variables as the Launch Action.



26
27
28
# File 'lib/xcodeproj/scheme/test_action.rb', line 26

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

#testablesArray<TestableReference>

Returns The list of TestableReference (test bundles) associated with this Test Action.

Returns:

  • (Array<TestableReference>)

    The list of TestableReference (test bundles) associated with this Test Action



71
72
73
74
75
76
77
# File 'lib/xcodeproj/scheme/test_action.rb', line 71

def testables
  return [] unless @xml_element.elements['Testables']

  @xml_element.elements['Testables'].get_elements('TestableReference').map do |node|
    TestableReference.new(node)
  end
end