Skip to content

Commit

Permalink
Skipped tests list support added for TestableReference
Browse files Browse the repository at this point in the history
  • Loading branch information
somedev committed Jun 1, 2016
1 parent cd03f25 commit 8bfb591
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
43 changes: 43 additions & 0 deletions lib/xcodeproj/scheme/test_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,49 @@ def add_buildable_reference(ref)
@xml_element.add_element(ref.xml_element)
end

# @return [Array<SkippedTest>]
# The list of SkippedTest this action will skip.
#
def skipped_tests
@xml_element.elements['SkippedTests'].get_elements('Test').map do |node|
TestableReference::SkippedTest.new(node)
end
end

# @param [SkippedTest] skipped_test
# The SkippedTest to add to the list of tests this action will skip
#
def add_skipped_test(skipped_test)
entries = @xml_element.elements['SkippedTests'] || @xml_element.add_element('SkippedTests')
entries.add_element(skipped_test.xml_element)
end

class SkippedTest < XMLElementWrapper
# @param [REXML::Element] node
# The 'Test' XML node that this object will wrap.
# If nil, will create a default XML node to use.
#
def initialize(node = nil)
create_xml_element_with_fallback(node, 'Test') do
self.identifier = node.attributes['Identifier'] unless node.nil?
end
end

# @return [String]
# Skipped test class name
#
def identifier
@xml_element.attributes['Identifier']
end

# @param [String] value
# Set the name of the skipped test class name
#
def identifier=(value)
@xml_element.attributes['Identifier'] = value
end
end

# @todo handle 'AdditionalOptions' tag
end
end
Expand Down
27 changes: 27 additions & 0 deletions spec/scheme/test_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,33 @@ module Xcodeproj
specs_for_bool_attr(attributes)
end

it '#add_skipped_test' do
test_ref = XCScheme::TestAction::TestableReference.new
skipped_test = XCScheme::TestAction::TestableReference::SkippedTest.new
skipped_test.identifier = 'MyClassTests'
test_ref.add_skipped_test(skipped_test)
test_ref.xml_element.elements['SkippedTests'].should.not.nil?
test_ref.xml_element.elements['SkippedTests'].count.should == 1
test_ref.xml_element.elements['SkippedTests'].elements['Test'].should == skipped_test.xml_element
end

it '#skipped_tests' do
test_ref = XCScheme::TestAction::TestableReference.new

test1 = XCScheme::TestAction::TestableReference::SkippedTest.new
test1.identifier = 'MyClassTests1'
test_ref.add_skipped_test(test1)

test2 = XCScheme::TestAction::TestableReference::SkippedTest.new
test2.identifier = 'MyClassTests2'
test_ref.add_skipped_test(test2)

test_ref.skipped_tests.count.should == 2
test_ref.skipped_tests.all? { |e| e.class.should == XCScheme::TestAction::TestableReference::SkippedTest }
test_ref.skipped_tests[0].xml_element.should == test1.xml_element
test_ref.skipped_tests[1].xml_element.should == test2.xml_element
end

it '#add_buildable_reference' do
project = Xcodeproj::Project.new('/foo/bar/baz.xcodeproj')
test_ref = XCScheme::TestAction::TestableReference.new
Expand Down

0 comments on commit 8bfb591

Please sign in to comment.