Skip to content

Commit 102cf89

Browse files
authored
test: use sdk override enums in UI test code (#5623)
1 parent 0529194 commit 102cf89

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

Samples/iOS-Swift/iOS-Swift-UITests/BaseUITest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import SentrySampleShared
12
import SentrySampleUITestShared
23
import XCTest
34

45
class BaseUITest: XCTestCase {
56
internal lazy var app: XCUIApplication = newAppSession()
6-
7+
78
//swiftlint:disable implicit_getter
89
var automaticallyLaunchAndTerminateApp: Bool { get { true } }
910
//swiftlint:enable implicit_getter
@@ -20,7 +21,7 @@ class BaseUITest: XCTestCase {
2021
launchApp()
2122
}
2223
}
23-
24+
2425
override func tearDown() {
2526
if automaticallyLaunchAndTerminateApp {
2627
app.terminate()
@@ -33,7 +34,7 @@ extension BaseUITest {
3334
func newAppSession() -> XCUIApplication {
3435
let app = XCUIApplication()
3536
app.launchEnvironment["--io.sentry.ui-test.test-name"] = name
36-
app.launchArguments.append("--io.sentry.other.disable-spotlight")
37+
app.launchArguments.append(SentrySDKOverrides.Other.disableSpotlight.rawValue)
3738
return app
3839
}
3940

@@ -67,5 +68,4 @@ extension BaseUITest {
6768
func waitForExistenceOfMainScreen() {
6869
app.waitForExistence("Home Screen doesn't exist.")
6970
}
70-
7171
}

Samples/iOS-Swift/iOS-Swift-UITests/ProfilingUITests.swift

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@testable import Sentry
2+
import SentrySampleShared
23
import XCTest
34

45
//swiftlint:disable function_body_length todo
@@ -44,14 +45,14 @@ class ProfilingUITests: BaseUITest {
4445
func testProfilingGPUInfo() throws {
4546
if #available(iOS 16, *) {
4647
app.launchArguments.append(contentsOf: [
47-
"--io.sentry.wipe-data",
48+
SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue,
4849

4950
// we're only interested in the manual transaction, the automatic stuff messes up how we try to retrieve the target profile info
50-
"--io.sentry.other.disable-swizzling",
51+
SentrySDKOverrides.Other.disableSwizzling.rawValue,
5152

52-
"--io.sentry.profiling.disable-app-start-profiling"
53+
SentrySDKOverrides.Profiling.disableAppStartProfiling.rawValue
5354
])
54-
app.launchEnvironment["--io.sentry.profiling.profilesSampleRate"] = "1.0"
55+
app.launchEnvironment[SentrySDKOverrides.Profiling.sampleRate.rawValue] = "1.0"
5556
launchApp()
5657

5758
goToTransactions()
@@ -144,36 +145,36 @@ extension ProfilingUITests {
144145
fileprivate func setAppLaunchParameters(_ profileType: ProfilingUITests.ProfilingType, _ lifecycle: SentryProfileOptions.SentryProfileLifecycle?, _ shouldProfileNextLaunch: Bool) {
145146
app.launchArguments.append(contentsOf: [
146147
// these help avoid other profiles that'd be taken automatically, that interfere with the checking we do for the assertions later in the tests
147-
"--io.sentry.other.disable-swizzling",
148-
"--io.sentry.performance.disable-auto-performance-tracing",
149-
"--io.sentry.performance.disable-uiviewcontroller-tracing",
148+
SentrySDKOverrides.Other.disableSwizzling.rawValue,
149+
SentrySDKOverrides.Performance.disablePerformanceTracing.rawValue,
150+
SentrySDKOverrides.Performance.disableUIVCTracing.rawValue,
150151

151152
// sets a marker function to run in a load command that the launch profile should detect
152-
"--io.sentry.profiling.slow-load-method",
153+
SentrySDKOverrides.Profiling.slowLoadMethod.rawValue,
153154

154155
// override full chunk completion before stoppage introduced in https://github.com/getsentry/sentry-cocoa/pull/4214
155-
"--io.sentry.profiling.continuous-profiler-immediate-stop"
156+
SentrySDKOverrides.Profiling.immediateStop.rawValue
156157
])
157158

158159
switch profileType {
159160
case .ui:
160-
app.launchEnvironment["--io.sentry.profiling.profile-session-sample-rate"] = "1"
161+
app.launchEnvironment[SentrySDKOverrides.Profiling.sessionSampleRate.rawValue] = "1"
161162
switch lifecycle {
162163
case .none:
163164
fatalError("Misconfigured test case. Must provide a lifecycle for UI profiling.")
164165
case .trace:
165166
break
166167
case .manual:
167-
app.launchArguments.append("--io.sentry.profiling.profile-lifecycle-manual")
168+
app.launchArguments.append(SentrySDKOverrides.Profiling.manualLifecycle.rawValue)
168169
}
169170
case .continuous:
170-
app.launchArguments.append("--io.sentry.profiling.disable-ui-profiling")
171+
app.launchArguments.append(SentrySDKOverrides.Profiling.disableUIProfiling.rawValue)
171172
case .trace:
172-
app.launchEnvironment["--io.sentry.profiling.profilesSampleRate"] = "1"
173+
app.launchEnvironment[SentrySDKOverrides.Profiling.sampleRate.rawValue] = "1"
173174
}
174175

175176
if !shouldProfileNextLaunch {
176-
app.launchArguments.append("--io.sentry.profiling.disable-app-start-profiling")
177+
app.launchArguments.append(SentrySDKOverrides.Profiling.disableAppStartProfiling.rawValue)
177178
}
178179
}
179180

Samples/iOS-Swift/iOS-Swift-UITests/ViewLifecycleUITests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import SentrySampleShared
12
import XCTest
23

34
// This is an UI test for a scenario that was previously crashing the SDK (see https://github.com/getsentry/sentry-cocoa/issues/5087 for details).
@@ -9,9 +10,9 @@ class ViewLifecycleUITests: BaseUITest {
910
override func setUp() {
1011
super.setUp()
1112
launchApp(args: [
12-
"--io.sentry.performance.disable-time-to-full-display-tracing",
13-
"--io.sentry.performance.disable-performance-v2",
14-
"--io.sentry.performance.disable-app-hang-tracking-v2"
13+
SentrySDKOverrides.Performance.disableTimeToFullDisplayTracing.rawValue,
14+
SentrySDKOverrides.Performance.disablePerformanceV2.rawValue,
15+
SentrySDKOverrides.Performance.disableAppHangTrackingV2.rawValue
1516
])
1617
}
1718

Samples/iOS-Swift/iOS-Swift.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ targets:
7676
- iOS-Swift-UITests
7777
dependencies:
7878
- target: SentrySampleShared/SentrySampleUITestShared
79+
- target: SentrySampleShared/SentrySampleShared
7980
configFiles:
8081
Debug: iOS-Swift-UITests.xcconfig
8182
Release: iOS-Swift-UITests.xcconfig

Samples/iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import SentrySampleShared
12
import SentrySampleUITestShared
23
import XCTest
34

@@ -47,13 +48,13 @@ class LaunchUITests: XCTestCase {
4748

4849
XCTAssertEqual(app.staticTexts["TTDInfo"].label, "TTID and TTFD found")
4950
}
50-
51-
func newAppSession() -> XCUIApplication {
52-
let app = XCUIApplication()
53-
app.launchEnvironment["--io.sentry.ui-test.test-name"] = name
54-
app.launchArguments.append("--io.sentry.other.disable-spotlight")
55-
return app
56-
}
51+
52+
func newAppSession() -> XCUIApplication {
53+
let app = XCUIApplication()
54+
app.launchEnvironment["--io.sentry.ui-test.test-name"] = name
55+
app.launchArguments.append(SentrySDKOverrides.Other.disableSpotlight.rawValue)
56+
return app
57+
}
5758
}
5859

5960
extension XCUIApplication {

Samples/iOS-SwiftUI/iOS-SwiftUI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ targets:
5353
platform: auto
5454
dependencies:
5555
- target: SentrySampleShared/SentrySampleUITestShared
56+
- target: SentrySampleShared/SentrySampleShared
5657
sources:
5758
- iOS-SwiftUI-UITests
5859
configFiles:

Samples/macOS-Swift/macOS-Swift-UITests/MacOSSwiftUITests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import SentrySampleShared
12
import XCTest
23

34
final class MacOSSwiftUITests: XCTestCase {
@@ -57,21 +58,21 @@ private extension MacOSSwiftUITests {
5758
) throws {
5859
app.launchArguments.append(contentsOf: [
5960
// these help avoid other profiles that'd be taken automatically, that interfere with the checking we do for the assertions later in the tests
60-
"--io.sentry.other.disable-swizzling",
61-
"--io.sentry.performance.disable-auto-performance-tracing",
62-
"--io.sentry.performance.disable-uiviewcontroller-tracing",
61+
SentrySDKOverrides.Other.disableSwizzling.rawValue,
62+
SentrySDKOverrides.Performance.disablePerformanceTracing.rawValue,
63+
SentrySDKOverrides.Performance.disableUIVCTracing.rawValue,
6364

6465
// sets a marker function to run in a load command that the launch profile should detect
65-
"--io.sentry.profiling.slow-load-method",
66+
SentrySDKOverrides.Profiling.slowLoadMethod.rawValue,
6667

6768
// override full chunk completion before stoppage introduced in https://github.com/getsentry/sentry-cocoa/pull/4214
68-
"--io.sentry.continuous-profiler-immediate-stop"
69+
SentrySDKOverrides.Profiling.immediateStop.rawValue
6970
])
7071

7172
app.launchEnvironment["--io.sentry.ui-test.test-name"] = name
7273

7374
if !shouldProfileNextLaunch {
74-
app.launchArguments.append("--io.sentry.profiling.disable-app-start-profiling")
75+
app.launchArguments.append(SentrySDKOverrides.Profiling.disableAppStartProfiling.rawValue)
7576
}
7677

7778
app.launch()

Samples/macOS-Swift/macOS-Swift.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ targets:
5454
- target: macOS-Swift-Other
5555
- target: macOS-Swift-Sandboxed
5656
- target: macOS-Swift-Sandboxed-Other
57+
- target: SentrySampleShared/SentrySampleShared
5758
configFiles:
5859
Debug: macOS-Swift-UITests.xcconfig
5960
Release: macOS-Swift-UITests.xcconfig

0 commit comments

Comments
 (0)