Skip to content

Commit 973cc2f

Browse files
test: Fix test conventions from develop-docs review
- Rename tests to follow test_when_should naming convention - Fix assertion order: value first, expected second - Remove unnecessary force_unwrapping swiftlint disable
1 parent 9d19a2a commit 973cc2f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Tests/SentryTests/Integrations/Performance/AppStartTracking/SentryAppStartTrackerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
348348
assertValidHybridStart(type: .warm)
349349
}
350350

351-
func testStandaloneAppStartTracing_SDKNotEnabled_DropsAppStart() {
351+
func testStart_whenStandaloneAppStartTracingAndSDKNotEnabled_shouldDropAppStart() {
352352
fixture.enableStandaloneAppStartTracing = true
353353
startApp(callDisplayLink: true)
354354

@@ -357,7 +357,7 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
357357
assertNoAppStartUp()
358358
}
359359

360-
func testStandaloneAppStartTracingDisabled_SetsAppStartMeasurement() {
360+
func testStart_whenStandaloneAppStartTracingDisabled_shouldSetAppStartMeasurement() {
361361
fixture.enableStandaloneAppStartTracing = false
362362
startApp(callDisplayLink: true)
363363

Tests/SentryTests/Transaction/SentryBuildAppStartSpansTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class SentryBuildAppStartSpansTests: XCTestCase {
207207
)
208208
}
209209

210-
func testStandalone_coldNotPrewarmed_noGroupingSpan() {
210+
func testBuildStandaloneAppStartSpans_whenColdNotPrewarmed_shouldNotIncludeGroupingSpan() {
211211
// Arrange
212212
let context = SpanContext(operation: "operation")
213213
let tracer = SentryTracer(context: context, framesTracker: nil)
@@ -280,7 +280,7 @@ class SentryBuildAppStartSpansTests: XCTestCase {
280280
)
281281
}
282282

283-
func testStandalone_prewarmed_noGroupingSpan() {
283+
func testBuildStandaloneAppStartSpans_whenPrewarmed_shouldNotIncludeGroupingSpan() {
284284
// Arrange
285285
let context = SpanContext(operation: "operation")
286286
let tracer = SentryTracer(context: context, framesTracker: nil)

Tests/SentryTests/Transaction/SentryTracerTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import _SentryPrivate
33
@_spi(Private) import SentryTestUtils
44
import XCTest
55

6-
// swiftlint:disable file_length type_body_length force_unwrapping
6+
// swiftlint:disable file_length type_body_length
77
// We are aware that the tracer has a lot of logic and we should maybe
88
// move some of it to other classes.
99
class SentryTracerTests: XCTestCase {
@@ -964,7 +964,7 @@ class SentryTracerTests: XCTestCase {
964964
XCTAssertNil(serializedTransaction?["debug_meta"])
965965
}
966966

967-
func testStandaloneAppStart_UsesConfigurationMeasurement() throws {
967+
func testFinish_whenStandaloneAppStart_shouldUseConfigurationMeasurement() throws {
968968
let appStartMeasurement = fixture.getAppStartMeasurement(type: .cold)
969969

970970
let context = TransactionContext(name: "App Start Cold", operation: fixture.appStartColdOperation)
@@ -990,7 +990,7 @@ class SentryTracerTests: XCTestCase {
990990
// Standalone transactions have no intermediate grouping span, so 5 child spans
991991
// (not 6) for a non-prewarmed cold start.
992992
let spans = try XCTUnwrap(serializedTransaction["spans"] as? [[String: Any]])
993-
XCTAssertEqual(5, spans.count)
993+
XCTAssertEqual(spans.count, 5)
994994

995995
let spanDescriptions = spans.compactMap { $0["description"] as? String }
996996
let spanOperations = spans.compactMap { $0["op"] as? String }
@@ -1005,7 +1005,7 @@ class SentryTracerTests: XCTestCase {
10051005
XCTAssertEqual(Set(spanOperations), ["app.start.cold"])
10061006
}
10071007

1008-
func testStandaloneAppStart_BothConfigAndGlobalSet_ConfigWins_GlobalMarkedAsRead() throws {
1008+
func testFinish_whenBothConfigAndGlobalAppStartSet_shouldUseConfigAndMarkGlobalAsRead() throws {
10091009
// In practice only one of config or global should be set, never both. This test
10101010
// verifies that if both happen to be set, the config measurement wins and the
10111011
// global static is marked as read so no UIViewController transaction consumes it.

0 commit comments

Comments
 (0)