class Xcodeproj::XCScheme::TestAction
This class wraps the TestAction
node of a .xcscheme XML file
Public Class Methods
new(node = nil)
click to toggle source
@param [REXML::Element] node
The 'TestAction' XML node that this object will wrap. If nil, will create a default XML node to use.
# File lib/xcodeproj/scheme/test_action.rb, line 12 def initialize(node = nil) create_xml_element_with_fallback(node, 'TestAction') do self.build_configuration = 'Debug' @xml_element.attributes['selectedDebuggerIdentifier'] = 'Xcode.DebuggerFoundation.Debugger.LLDB' @xml_element.attributes['selectedLauncherIdentifier'] = 'Xcode.DebuggerFoundation.Launcher.LLDB' self.should_use_launch_scheme_args_env = true @xml_element.add_element('Testables') end end
Public Instance Methods
add_code_coverage_target(buildable_reference)
click to toggle source
@param [BuildableReference] buildable_reference
Add a BuildableReference (code coverage target) to this Test Action
# File lib/xcodeproj/scheme/test_action.rb, line 183 def add_code_coverage_target(buildable_reference) @xml_element.attributes['onlyGenerateCoverageForSpecifiedTargets'] = bool_to_string(true) coverage_targets_element = @xml_element.elements['CodeCoverageTargets'] || @xml_element.add_element('CodeCoverageTargets') coverage_targets_element.add_element(buildable_reference.xml_element) code_coverage_targets end
add_macro_expansion(macro_expansion)
click to toggle source
@param [MacroExpansion] macro_expansion
Add a MacroExpansion to this TestAction
# File lib/xcodeproj/scheme/test_action.rb, line 111 def add_macro_expansion(macro_expansion) if testables = @xml_element.elements['Testables'] @xml_element.insert_before(testables, macro_expansion.xml_element) else @xml_element.add_element(macro_expansion.xml_element) end end
add_testable(testable)
click to toggle source
@param [TestableReference] testable
Add a TestableReference (test bundle) to this Test Action
# File lib/xcodeproj/scheme/test_action.rb, line 94 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)
click to toggle source
@param [Bool] flag
Set whether Clang Code Coverage is enabled ('Gather coverage data' turned ON)
# 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?()
click to toggle source
@return [Bool]
Whether Clang Code Coverage is enabled ('Gather coverage data' turned ON)
# File lib/xcodeproj/scheme/test_action.rb, line 57 def code_coverage_enabled? string_to_bool(@xml_element.attributes['codeCoverageEnabled']) end
code_coverage_targets()
click to toggle source
@return [Array<BuildableReference>]
The list of BuildableReference (code coverage targets) associated with this Test Action
# File lib/xcodeproj/scheme/test_action.rb, line 157 def code_coverage_targets return [] unless @xml_element.elements['CodeCoverageTargets'] @xml_element.elements['CodeCoverageTargets'].get_elements('BuildableReference').map do |node| BuildableReference.new(node) end end
code_coverage_targets=(buildable_references)
click to toggle source
@param [Array<BuildableReference>] buildable_references
Sets the list of BuildableReference (code coverage targets) associated with this Test Action
# File lib/xcodeproj/scheme/test_action.rb, line 168 def code_coverage_targets=(buildable_references) @xml_element.attributes['onlyGenerateCoverageForSpecifiedTargets'] = bool_to_string(true) @xml_element.delete_element('CodeCoverageTargets') coverage_targets_element = @xml_element.add_element('CodeCoverageTargets') buildable_references.each do |reference| coverage_targets_element.add_element(reference.xml_element) end code_coverage_targets end
command_line_arguments()
click to toggle source
@return [CommandLineArguments]
Returns the CommandLineArguments that will be passed at app launch
# File lib/xcodeproj/scheme/test_action.rb, line 141 def command_line_arguments CommandLineArguments.new(@xml_element.elements[XCScheme::COMMAND_LINE_ARGS_NODE]) end
command_line_arguments=(arguments)
click to toggle source
@return [CommandLineArguments] arguments
Sets the CommandLineArguments that will be passed at app launch
# File lib/xcodeproj/scheme/test_action.rb, line 148 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)
click to toggle source
@param [Bool] flag
Set whether this Test Action should disable detection of UI API misuse from background threads
# 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?()
click to toggle source
@return [Bool]
Whether this Test Action should disable detection of UI API misuse from background threads
# File lib/xcodeproj/scheme/test_action.rb, line 42 def disable_main_thread_checker? string_to_bool(@xml_element.attributes['disableMainThreadChecker']) end
environment_variables()
click to toggle source
@return [EnvironmentVariables]
Returns the EnvironmentVariables that will be defined at test launch
# File lib/xcodeproj/scheme/test_action.rb, line 122 def environment_variables EnvironmentVariables.new(@xml_element.elements[XCScheme::VARIABLES_NODE]) end
environment_variables=(env_vars)
click to toggle source
@param [EnvironmentVariables,nil] env_vars
Sets the EnvironmentVariables that will be defined at test launch
@return [EnvironmentVariables]
# File lib/xcodeproj/scheme/test_action.rb, line 130 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_expansions()
click to toggle source
@return [Array<MacroExpansion>]
The list of MacroExpansion bound with this TestAction
# File lib/xcodeproj/scheme/test_action.rb, line 102 def macro_expansions @xml_element.get_elements('MacroExpansion').map do |node| MacroExpansion.new(node) end end
should_use_launch_scheme_args_env=(flag)
click to toggle source
@param [Bool] flag
Set whether this Test Action should use the same arguments and environment variables as the Launch Action.
# 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?()
click to toggle source
@return [Bool]
Whether this Test Action should use the same arguments and environment variables as the Launch Action.
# File lib/xcodeproj/scheme/test_action.rb, line 26 def should_use_launch_scheme_args_env? string_to_bool(@xml_element.attributes['shouldUseLaunchSchemeArgsEnv']) end
testables()
click to toggle source
@return [Array<TestableReference>]
The list of TestableReference (test bundles) associated with this Test Action
# 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
testables=(testables)
click to toggle source
@param [Array<TestableReference>] testables
Sets the list of TestableReference (test bundles) associated with this Test Action
# File lib/xcodeproj/scheme/test_action.rb, line 82 def testables=(testables) @xml_element.delete_element('Testables') testables_element = @xml_element.add_element('Testables') testables.each do |testable| testables_element.add_element(testable.xml_element) end testables end