-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unhandled exception session test
- Loading branch information
1 parent
eb83295
commit fee3c43
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Android support | ||
|
||
Scenario: Test handled Android Exception | ||
When I run "UnhandledExceptionSessionScenario" with the defaults | ||
Then I should receive a request | ||
And the request is a valid for the error reporting API | ||
And the exception "errorClass" equals "java.lang.RuntimeException" | ||
And the exception "message" equals "UnhandledExceptionSessionScenario" | ||
And the event "session" is not null | ||
And the event "session.id" is not null | ||
And the event "session.startedAt" is not null | ||
And the event "session.events" is not null | ||
And the payload field "events.0.session.events.handled" equals 0 | ||
And the payload field "events.0.session.events.unhandled" equals 1 |
20 changes: 20 additions & 0 deletions
20
...c/main/java/com/bugsnag/android/mazerunner/scenarios/UnhandledExceptionSessionScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
|
||
/** | ||
* Sends an unhandled exception to Bugsnag, which includes session data. | ||
*/ | ||
internal class UnhandledExceptionSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
disableSessionDelivery() | ||
Bugsnag.startSession() | ||
throw generateException() | ||
} | ||
|
||
} |