Skip to content

Commit

Permalink
add unhandled exception session test
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Mar 1, 2018
1 parent eb83295 commit fee3c43
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions features/unhandled_exception_session.feature
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
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()
}

}

0 comments on commit fee3c43

Please sign in to comment.