Skip to content

Commit

Permalink
test: Set ui-tests environment (#3544)
Browse files Browse the repository at this point in the history
Set the up-tests environment when running UI tests in CI so that we can
apply filters in Sentry.
  • Loading branch information
philipphofmann authored Jan 5, 2024
1 parent e90aa6d commit 9ccd421
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions Samples/iOS-Swift/iOS-SwiftUITests/BaseUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9ccd421

Please sign in to comment.