Skip to content

Commit

Permalink
Merge pull request #383 from somedev/feature-skipped-tests
Browse files Browse the repository at this point in the history
Skipped tests list support
  • Loading branch information
segiddins committed Jun 7, 2016
2 parents 9188279 + d10e317 commit 1b15f4c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Add accessors for working with skipped tests inside TestAction in `.xcscheme` files.
[Eduard Panasiuk](https://github.com/somedev)
[#380](https://github.com/CocoaPods/Xcodeproj/pull/380)
[#383](https://github.com/CocoaPods/Xcodeproj/pull/383)

##### Bug Fixes

Expand Down
15 changes: 15 additions & 0 deletions lib/xcodeproj/scheme/test_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,26 @@ def add_buildable_reference(ref)
# The list of SkippedTest this action will skip.
#
def skipped_tests
return [] if @xml_element.elements['SkippedTests'].nil?
@xml_element.elements['SkippedTests'].get_elements('Test').map do |node|
TestableReference::SkippedTest.new(node)
end
end

# @param [Array<SkippedTest>] tests
# Set the list of SkippedTest this action will skip.
#
def skipped_tests=(tests)
@xml_element.delete_element('SkippedTests') unless @xml_element.elements['SkippedTests'].nil?
if tests.nil?
return
end
entries = @xml_element.add_element('SkippedTests')
tests.each do |skipped|
entries.add_element(skipped.xml_element)
end
end

# @param [SkippedTest] skipped_test
# The SkippedTest to add to the list of tests this action will skip
#
Expand Down
25 changes: 25 additions & 0 deletions spec/scheme/test_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,31 @@ module Xcodeproj
test_ref.xml_element.elements['SkippedTests'].elements['Test'].should == skipped_test.xml_element
end

it '#set_skipped_tests_nil' do
test_ref = XCScheme::TestAction::TestableReference.new
test_ref.skipped_tests = [XCScheme::TestAction::TestableReference::SkippedTest.new]
test_ref.skipped_tests.count.should == 1
test_ref.skipped_tests = nil
test_ref.xml_element.elements['SkippedTests'].should.nil?
test_ref.skipped_tests.count.should == 0
end

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

test1 = XCScheme::TestAction::TestableReference::SkippedTest.new
test1.identifier = 'MyClassTests1'

test2 = XCScheme::TestAction::TestableReference::SkippedTest.new
test2.identifier = 'MyClassTests2'

test_ref.skipped_tests = [test1, 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 '#skipped_tests' do
test_ref = XCScheme::TestAction::TestableReference.new

Expand Down

0 comments on commit 1b15f4c

Please sign in to comment.