Skip to content

Commit

Permalink
Add tests for setter for skipped tests array
Browse files Browse the repository at this point in the history
  • Loading branch information
somedev committed Jun 7, 2016
1 parent 590cd9b commit 98290c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/xcodeproj/scheme/test_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ 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
Expand All @@ -162,7 +163,9 @@ def skipped_tests
#
def skipped_tests=(tests)
@xml_element.delete_element('SkippedTests') unless @xml_element.elements['SkippedTests'].nil?
return if tests.nil?
if tests.nil?
return
end
entries = @xml_element.add_element('SkippedTests')
tests.each do |skipped|
entries.add_element(skipped.xml_element)
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 98290c0

Please sign in to comment.