From 590cd9b0019244f6825941b468e0058ebf7e47df Mon Sep 17 00:00:00 2001 From: Eduard Panasiuk Date: Sun, 5 Jun 2016 12:19:31 +0300 Subject: [PATCH 1/3] Add setter for skipped tests array --- lib/xcodeproj/scheme/test_action.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/xcodeproj/scheme/test_action.rb b/lib/xcodeproj/scheme/test_action.rb index ff4eb0a45..6622981c2 100644 --- a/lib/xcodeproj/scheme/test_action.rb +++ b/lib/xcodeproj/scheme/test_action.rb @@ -157,6 +157,18 @@ def skipped_tests end end + # @param [Array] 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? + return if tests.nil? + 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 # From 98290c0cd71508f998cd5bf94c18f2596a9a4774 Mon Sep 17 00:00:00 2001 From: Eduard Panasiuk Date: Tue, 7 Jun 2016 20:59:48 +0300 Subject: [PATCH 2/3] Add tests for setter for skipped tests array --- lib/xcodeproj/scheme/test_action.rb | 5 ++++- spec/scheme/test_action_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/xcodeproj/scheme/test_action.rb b/lib/xcodeproj/scheme/test_action.rb index 6622981c2..6d484098e 100644 --- a/lib/xcodeproj/scheme/test_action.rb +++ b/lib/xcodeproj/scheme/test_action.rb @@ -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 @@ -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) diff --git a/spec/scheme/test_action_spec.rb b/spec/scheme/test_action_spec.rb index 601089a1e..806d5adae 100644 --- a/spec/scheme/test_action_spec.rb +++ b/spec/scheme/test_action_spec.rb @@ -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 From d10e317bdadb6e33885d623c009764d6b4d34c4d Mon Sep 17 00:00:00 2001 From: Eduard Panasiuk Date: Tue, 7 Jun 2016 21:11:21 +0300 Subject: [PATCH 3/3] [CHANGELOG] Added PR link --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ab9aa13..4ce13ba11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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