From dbaf866c95737f5fc82f781301ee64f0107fdc5d Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Fri, 5 Jan 2024 11:13:33 +0100 Subject: [PATCH] test: Set ui-tests environment (#3544) Set the up-tests environment when running UI tests in CI so that we can apply filters in Sentry. --- Samples/iOS-Swift/iOS-Swift/AppDelegate.swift | 12 ++++++++++-- Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Samples/iOS-Swift/iOS-Swift/AppDelegate.swift b/Samples/iOS-Swift/iOS-Swift/AppDelegate.swift index 9e530c19463..a8503af26ab 100644 --- a/Samples/iOS-Swift/iOS-Swift/AppDelegate.swift +++ b/Samples/iOS-Swift/iOS-Swift/AppDelegate.swift @@ -29,7 +29,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { options.profilesSampleRate = 1.0 options.attachScreenshot = true options.attachViewHierarchy = true - options.environment = "test-app" options.enableTimeToFullDisplayTracing = true options.enablePerformanceV2 = true @@ -65,7 +64,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } options.initialScope = { scope in - scope.setEnvironment("debug") + let processInfoEnvironment = ProcessInfo.processInfo.environment["io.sentry.sdk-environment"] + + if processInfoEnvironment != nil { + scope.setEnvironment(processInfoEnvironment) + } else if isBenchmarking { + scope.setEnvironment("benchmarking") + } else { + scope.setEnvironment("debug") + } + scope.setTag(value: "swift", key: "language") let user = User(userId: "1") diff --git a/Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift b/Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift index 83abaa4f29d..94914d37c79 100644 --- a/Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift +++ b/Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift @@ -8,6 +8,7 @@ class BaseUITest: XCTestCase { continueAfterFailure = false XCUIDevice.shared.orientation = .portrait app.launchEnvironment["io.sentry.ui-test.test-name"] = name + app.launchEnvironment["io.sentry.sdk-environment"] = "ui-tests" app.launch() waitForExistenceOfMainScreen()