From 396bdc364d23649f6ae787bb45e6789e5442f464 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 10 Jul 2020 18:24:08 -0700 Subject: [PATCH 1/3] Turn off failing XCTest attachment collection --- .../xcshareddata/xcschemes/IosUnitTests.xcscheme | 3 ++- .../xcshareddata/xcschemes/Scenarios.xcscheme | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/xcshareddata/xcschemes/IosUnitTests.xcscheme b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/xcshareddata/xcschemes/IosUnitTests.xcscheme index 3c05147cb501b..503fa272ca433 100644 --- a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/xcshareddata/xcschemes/IosUnitTests.xcscheme +++ b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/xcshareddata/xcschemes/IosUnitTests.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + systemAttachmentLifetime = "keepNever"> diff --git a/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme b/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme index ebe5b1035abde..45f9a68a0179b 100644 --- a/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme +++ b/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + systemAttachmentLifetime = "keepNever"> Date: Mon, 13 Jul 2020 17:26:33 -0700 Subject: [PATCH 2/3] Only save golden attachments when they don't match or can't be found --- .../GoldenPlatformViewTests.m | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m index a3658e337fcca..f981fdb707d6e 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m @@ -48,22 +48,25 @@ - (void)checkGolden { GoldenImage* golden = self.manager.goldenImage; XCUIScreenshot* screenshot = [[XCUIScreen mainScreen] screenshot]; - XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; - attachment.name = @"new_golden"; - attachment.lifetime = XCTAttachmentLifetimeKeepAlways; - [self addAttachment:attachment]; - - if (golden.image) { - XCTAttachment* goldenAttachment = [XCTAttachment attachmentWithImage:golden.image]; - attachment.name = @"current_golden"; - goldenAttachment.lifetime = XCTAttachmentLifetimeKeepAlways; - [self addAttachment:goldenAttachment]; - } else { + if (!golden.image) { + XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot]; + attachment.name = @"new_golden"; + attachment.lifetime = XCTAttachmentLifetimeKeepAlways; + [self addAttachment:attachment]; XCTFail(@"This test will fail - no golden named %@ found. Follow the steps in the " @"README to add a new golden.", golden.goldenName); } - XCTAssertTrue([golden compareGoldenToImage:screenshot.image]); + if (![golden compareGoldenToImage:screenshot.image]) { + XCTAttachment* goldenAttachment; + goldenAttachment = [XCTAttachment attachmentWithImage:golden.image]; + goldenAttachment.name = @"current_golden"; + goldenAttachment.lifetime = XCTAttachmentLifetimeKeepAlways; + [self addAttachment:goldenAttachment]; + + XCTFail(@"Goldens to not match. Follow the steps in the " + @"README update golden named %@ if needed.", golden.goldenName); + } } @end From 68c7e74092f3f133618637dd9bcee4f68b59896c Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 13 Jul 2020 17:51:32 -0700 Subject: [PATCH 3/3] Format --- .../ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m index f981fdb707d6e..4187abfe9e9aa 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m @@ -66,7 +66,8 @@ - (void)checkGolden { [self addAttachment:goldenAttachment]; XCTFail(@"Goldens to not match. Follow the steps in the " - @"README update golden named %@ if needed.", golden.goldenName); + @"README to update golden named %@ if needed.", + golden.goldenName); } } @end