@@ -25,6 +25,15 @@ void main() {
25
25
.thenAnswer ((_) async => SentryId .empty ());
26
26
}
27
27
28
+ Future <void > registerIntegration (Fixture fixture) async {
29
+ await fixture.registerIntegration ();
30
+ // Wait for the app start info to be fetched
31
+ // This ensures that setAppStartInfo has been called, which happens asynchronously
32
+ // in a post-frame callback. Waiting here prevents race conditions in subsequent tests
33
+ // that might depend on or modify the app start info.
34
+ await NativeAppStartIntegration .getAppStartInfo ();
35
+ }
36
+
28
37
group ('$NativeAppStartIntegration ' , () {
29
38
late Fixture fixture;
30
39
@@ -44,8 +53,7 @@ void main() {
44
53
NativeAppStartIntegration .appStartEnd =
45
54
DateTime .fromMillisecondsSinceEpoch (10 );
46
55
47
- await fixture.registerIntegration ();
48
-
56
+ await registerIntegration (fixture);
49
57
final tracer = fixture.createTracer ();
50
58
final transaction = SentryTransaction (tracer);
51
59
@@ -63,8 +71,7 @@ void main() {
63
71
NativeAppStartIntegration .appStartEnd =
64
72
DateTime .fromMillisecondsSinceEpoch (10 );
65
73
66
- await fixture.registerIntegration ();
67
-
74
+ await registerIntegration (fixture);
68
75
final tracer = fixture.createTracer ();
69
76
final transaction = SentryTransaction (tracer);
70
77
@@ -83,8 +90,7 @@ void main() {
83
90
DateTime .fromMillisecondsSinceEpoch (10 );
84
91
final measurement = SentryMeasurement .warmAppStart (Duration (seconds: 1 ));
85
92
86
- await fixture.registerIntegration ();
87
-
93
+ await registerIntegration (fixture);
88
94
final tracer = fixture.createTracer ();
89
95
final transaction = SentryTransaction (tracer).copyWith ();
90
96
transaction.measurements[measurement.name] = measurement;
@@ -104,8 +110,7 @@ void main() {
104
110
NativeAppStartIntegration .appStartEnd =
105
111
DateTime .fromMillisecondsSinceEpoch (60001 );
106
112
107
- await fixture.registerIntegration ();
108
-
113
+ await registerIntegration (fixture);
109
114
final tracer = fixture.createTracer ();
110
115
final transaction = SentryTransaction (tracer);
111
116
@@ -121,8 +126,7 @@ void main() {
121
126
NativeAppStartIntegration .appStartEnd =
122
127
DateTime .fromMillisecondsSinceEpoch (10 );
123
128
124
- await fixture.registerIntegration ();
125
-
129
+ await registerIntegration (fixture);
126
130
final appStartInfo = await NativeAppStartIntegration .getAppStartInfo ();
127
131
expect (appStartInfo? .start, DateTime .fromMillisecondsSinceEpoch (0 ));
128
132
expect (appStartInfo? .end, DateTime .fromMillisecondsSinceEpoch (10 ));
@@ -133,7 +137,7 @@ void main() {
133
137
() async {
134
138
fixture.options.autoAppStart = false ;
135
139
136
- await fixture. registerIntegration ();
140
+ await registerIntegration (fixture );
137
141
138
142
final tracer = fixture.createTracer ();
139
143
final transaction = SentryTransaction (tracer);
@@ -155,8 +159,7 @@ void main() {
155
159
const Duration (seconds: 5 ));
156
160
fixture.options.autoAppStart = false ;
157
161
158
- await fixture.registerIntegration ();
159
-
162
+ await registerIntegration (fixture);
160
163
final tracer = fixture.createTracer ();
161
164
final transaction = SentryTransaction (tracer);
162
165
@@ -175,8 +178,7 @@ void main() {
175
178
() async {
176
179
fixture.options.autoAppStart = false ;
177
180
178
- await fixture.registerIntegration ();
179
-
181
+ await registerIntegration (fixture);
180
182
SentryFlutter .setAppStartEnd (DateTime .fromMillisecondsSinceEpoch (10 ));
181
183
182
184
final tracer = fixture.createTracer ();
@@ -272,8 +274,7 @@ void main() {
272
274
when (fixture.binding.fetchNativeAppStart ())
273
275
.thenAnswer ((_) async => appStartInfoSrc);
274
276
275
- await fixture.registerIntegration ();
276
-
277
+ await registerIntegration (fixture);
277
278
final processor = fixture.options.eventProcessors.first;
278
279
tracer = fixture.createTracer ();
279
280
final transaction = SentryTransaction (tracer);
0 commit comments