Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions test/Sentry.Unity.Android.Tests/SentryJavaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,18 @@ public void RunJniSafe_ActionThrowsOnMainThread_CatchesExceptionAndLogsError()
public void RunJniSafe_ActionThrowsOnNonMainThread_CatchesExceptionAndLogsError()
{
// Arrange
var exception = new InvalidOperationException("Test exception");
var resetEvent = new ManualResetEvent(false);
var action = new Action(() =>
{
try
{
throw exception;
}
finally
{
resetEvent.Set();
}
});
var action = new Action(() => throw new InvalidOperationException("Test exception"));

// Act
_sut.RunJniSafe(action, "TestAction", isMainThread: false);

// Assert
Assert.That(resetEvent.WaitOne(TimeSpan.FromSeconds(1)), Is.True);
Assert.IsTrue(_logger.Logs.Any(log =>
log.logLevel == SentryLevel.Error &&
log.message.Contains("Calling 'TestAction' failed.")));
// Assert - wait for the error to be logged on the worker thread
var logFound = SpinWait.SpinUntil(() =>
_logger.Logs.Any(log =>
log.logLevel == SentryLevel.Error &&
log.message.Contains("Calling 'TestAction' failed.")),
TimeSpan.FromSeconds(1));
Assert.IsTrue(logFound);
}

[Test]
Expand Down