Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipped tests list support #383

Merged
merged 3 commits into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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