Skip to content

Commit ce94206

Browse files
Reintroduce CaptureException_RemoveScreenshot_NotContainsScreenshotAttachmentAsync
1 parent 527e09e commit ce94206

File tree

2 files changed

+17
-52
lines changed

2 files changed

+17
-52
lines changed

test/Sentry.Maui.Tests/Sentry.Maui.Tests.csproj

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,4 @@
2121
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
2222
</ItemGroup>
2323

24-
<!-- Disable all test files - comment out specific lines to re-enable tests -->
25-
<ItemGroup>
26-
<!-- <Compile Remove="ApiApprovalTests.verify.cs" />-->
27-
<!-- <Compile Remove="BindableSentryMauiOptionsTests.cs" />-->
28-
<!-- <Compile Remove="SentryMauiOptionsTests.cs" />-->
29-
<!-- <Compile Remove="SentryMauiAppBuilderExtensionsTests.cs" />-->
30-
<!-- <Compile Remove="SentryMauiAppBuilderExtensionsTests.Android.cs" />-->
31-
<!-- <Compile Remove="SentryMauiAppBuilderExtensionsTests.Cocoa.cs" />-->
32-
<!-- <Compile Remove="BreadcrumbEventTests.cs" />-->
33-
<!-- <Compile Remove="MauiNetworkStatusListenerTests.cs" />-->
34-
35-
<!-- <Compile Remove="MauiEventsBinderTests.Application.cs" />-->
36-
<!-- <Compile Remove="MauiEventsBinderTests.Element.cs" />-->
37-
<!-- <Compile Remove="MauiEventsBinderTests.Page.cs" />-->
38-
<!-- <Compile Remove="MauiEventsBinderTests.Shell.cs" />-->
39-
<!-- <Compile Remove="MauiEventsBinderTests.VisualElement.cs" />-->
40-
<!-- <Compile Remove="MauiEventsBinderTests.Window.cs" />-->
41-
<!-- <Compile Remove="MauiEventsBinderTests.cs" />-->
42-
43-
<!-- <Compile Remove="MauiButtonEventsBinderTests.cs" />-->
44-
<!-- <Compile Remove="MauiImageButtonEventsBinderTests.cs" />-->
45-
46-
<!-- <Compile Remove="MauiGestureRecognizerEventsBinderTests.cs" />-->
47-
48-
<!-- <Compile Remove="MauiVisualElementEventsBinderTests.cs" />-->
49-
50-
<!-- <Compile Remove="SentryMauiLogcatsTests.cs" />-->
51-
52-
<Compile Remove="SentryMauiScreenshotTests.cs" />
53-
</ItemGroup>
54-
5524
</Project>

test/Sentry.Maui.Tests/SentryMauiScreenshotTests.cs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task CaptureException_WhenAttachScreenshots_ContainsScreenshotAttac
5353
var builder = _fixture.Builder.UseSentry();
5454

5555
// Act
56-
using var app = builder.Build();
56+
await using var app = builder.Build();
5757
var client = app.Services.GetRequiredService<ISentryClient>();
5858
var sentryId = client.CaptureException(new Exception());
5959
await client.FlushAsync();
@@ -94,13 +94,11 @@ public async Task CaptureException_RemoveScreenshot_NotContainsScreenshotAttachm
9494
));
9595

9696
// Act
97-
using var app = builder.Build();
97+
await using var app = builder.Build();
9898
var client = app.Services.GetRequiredService<ISentryClient>();
9999
var sentryId = client.CaptureException(new Exception());
100100
await client.FlushAsync();
101101

102-
var options = app.Services.GetRequiredService<IOptions<SentryMauiOptions>>().Value;
103-
104102
var envelope = _fixture.Transport.GetSentEnvelopes().FirstOrDefault(e => e.TryGetEventId() == sentryId);
105103
envelope.Should().NotBeNull();
106104

@@ -116,22 +114,21 @@ public async Task CaptureException_BeforeCaptureScreenshot_DisableCaptureAsync()
116114
#if __IOS__
117115
Skip.If(true, "Flaky on iOS");
118116
#endif
117+
#if ANDROID
118+
Skip.If(TestEnvironment.IsGitHubActions, "Flaky in CI on Android");
119+
#endif
119120

120121
// Arrange
121-
var builder = _fixture.Builder.UseSentry(options => options.SetBeforeScreenshotCapture((e, hint) =>
122-
{
123-
return false;
124-
}
122+
var builder = _fixture.Builder.UseSentry(options => options.SetBeforeScreenshotCapture(
123+
(_, _) => false
125124
));
126125

127126
// Act
128-
using var app = builder.Build();
127+
await using var app = builder.Build();
129128
var client = app.Services.GetRequiredService<ISentryClient>();
130129
var sentryId = client.CaptureException(new Exception());
131130
await client.FlushAsync();
132131

133-
var options = app.Services.GetRequiredService<IOptions<SentryMauiOptions>>().Value;
134-
135132
var envelope = _fixture.Transport.GetSentEnvelopes().FirstOrDefault(e => e.TryGetEventId() == sentryId);
136133
envelope.Should().NotBeNull();
137134

@@ -157,10 +154,8 @@ public async Task CaptureException_BeforeCaptureScreenshot_DefaultAsync()
157154
#endif
158155

159156
// Arrange
160-
var builder = _fixture.Builder.UseSentry(options => options.SetBeforeScreenshotCapture((e, hint) =>
161-
{
162-
return true;
163-
}
157+
var builder = _fixture.Builder.UseSentry(options => options.SetBeforeScreenshotCapture(
158+
(_, _) => true
164159
));
165160

166161
// Act
@@ -184,19 +179,20 @@ public async Task CaptureException_BeforeCaptureScreenshot_DefaultAsync()
184179
}
185180
else
186181
{
187-
envelopeItem.Should().NotBeNull();
182+
envelopeItem.Should().NotBeNull();
188183
envelopeItem!.TryGetFileName().Should().Be("screenshot.jpg");
189184
}
190185
}
191186

192-
[Fact]
187+
[SkippableFact]
193188
public async Task CaptureException_AttachScreenshot_Threadsafe()
194189
{
190+
#if ANDROID
191+
Skip.If(TestEnvironment.IsGitHubActions, "Flaky in CI on Android");
192+
#endif
193+
195194
// Arrange
196-
var builder = _fixture.Builder.UseSentry(options =>
197-
{
198-
options.AttachScreenshot = true;
199-
});
195+
var builder = _fixture.Builder.UseSentry(options => options.AttachScreenshot = true);
200196
await using var app = builder.Build();
201197
var client = app.Services.GetRequiredService<ISentryClient>();
202198

0 commit comments

Comments
 (0)