-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test) added more end to end test for validated all the changeable…
… fields in an error callback (#2010)
- Loading branch information
1 parent
ebd33e6
commit 1c44dd1
Showing
3 changed files
with
147 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
86 changes: 86 additions & 0 deletions
86
...a/com/bugsnag/android/mazerunner/scenarios/UnhandledExceptionEventDetailChangeScenario.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,86 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.BreadcrumbType | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.OnErrorCallback | ||
import com.bugsnag.android.Severity | ||
|
||
/** | ||
* Sends an unhandled exception to Bugsnag where the event details are changed in a callback | ||
*/ | ||
internal class UnhandledExceptionEventDetailChangeScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
init { | ||
|
||
config.addOnError( | ||
OnErrorCallback { event -> | ||
event.apiKey = "0000111122223333aaaabbbbcccc9999" | ||
event.severity = Severity.ERROR | ||
event.groupingHash = "groupingHash1" | ||
event.context = "new-context" | ||
event.setUser("abc", "[email protected]", "Joe") | ||
|
||
event.clearMetadata("custom_data1") | ||
event.clearMetadata("custom_data2", "data") | ||
event.addMetadata("custom_data2", "test_data", "this is test") | ||
|
||
event.clearFeatureFlag("test1") | ||
event.addFeatureFlag("beta", "b") | ||
event.addFeatureFlag("gamma") | ||
|
||
event.isUnhandled = false | ||
event.app.binaryArch = "x86" | ||
event.app.id = "12345" | ||
event.app.releaseStage = "custom" | ||
event.app.version = "1.2.3" | ||
event.app.buildUuid = "12345678" | ||
event.app.type = "android_custom" | ||
event.app.versionCode = 123 | ||
event.app.duration = 123456 | ||
event.app.durationInForeground = 123456 | ||
event.app.inForeground = false | ||
event.app.isLaunching = false | ||
|
||
event.device.id = "12345" | ||
event.device.jailbroken = true | ||
event.device.locale = "en-UK" | ||
event.device.totalMemory = 123456 | ||
event.device.runtimeVersions = mutableMapOf("androidApiLevel" to "30") | ||
event.device.freeDisk = 123456 | ||
event.device.freeMemory = 123456 | ||
event.device.orientation = "portrait" | ||
|
||
event.breadcrumbs.removeLast() | ||
event.breadcrumbs.first().type = BreadcrumbType.ERROR | ||
event.breadcrumbs.first().message = "new breadcrumb message" | ||
event.breadcrumbs[1].type = BreadcrumbType.ERROR | ||
event.breadcrumbs[1].message = "Second breadcrumb message" | ||
event.breadcrumbs.first().metadata = mapOf("foo" to "data") | ||
true | ||
} | ||
) | ||
} | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
Bugsnag.leaveBreadcrumb("Hello1") | ||
Bugsnag.leaveBreadcrumb("Hello2") | ||
Bugsnag.leaveBreadcrumb("Hello3") | ||
|
||
Bugsnag.addMetadata("custom_data1", "data", "hello") | ||
Bugsnag.addMetadata("custom_data2", "data", "hello") | ||
Bugsnag.addMetadata("custom_data3", "test data", "divert all available power to the crash reporter") | ||
|
||
Bugsnag.addFeatureFlag("test1") | ||
Bugsnag.addFeatureFlag("test2") | ||
|
||
Bugsnag.notify(RuntimeException("UnhandledExceptionEventDetailChangeScenario")) | ||
throw NullPointerException("something broke") | ||
} | ||
} |
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,59 @@ | ||
Feature: When the api key is altered in an Event the JSON payload reflects this | ||
|
||
Background: | ||
Given I clear all persistent data | ||
|
||
Scenario: Unhandled exception with altered event details | ||
When I run "UnhandledExceptionEventDetailChangeScenario" and relaunch the crashed app | ||
And I configure Bugsnag for "UnhandledExceptionApiKeyChangeScenario" | ||
And I wait to receive an error | ||
And the error payload field "events" is an array with 1 elements | ||
And the exception "message" equals "UnhandledExceptionEventDetailChangeScenario" | ||
And the error payload field "apiKey" equals "0000111122223333aaaabbbbcccc9999" | ||
And the error "Bugsnag-Api-Key" header equals "0000111122223333aaaabbbbcccc9999" | ||
And the event "severity" equals "error" | ||
And the event "context" equals "new-context" | ||
And the event "groupingHash" equals "groupingHash1" | ||
And the event "user.id" equals "abc" | ||
And the event "user.email" equals "[email protected]" | ||
And the event "user.name" equals "Joe" | ||
And the event "metaData.custom_data2.test_data" equals "this is test" | ||
And the event "metaData.custom_data1" is null | ||
And the event "metaData.custom_data2.data" is null | ||
And the event "metaData.custom_data3.test data" equals "divert all available power to the crash reporter" | ||
And event 0 contains the feature flag "beta" with variant "b" | ||
And event 0 does not contain the feature flag "alpha" | ||
And event 0 contains the feature flag "gamma" with no variant | ||
And event 0 does not contain the feature flag "test1" | ||
And event 0 contains the feature flag "test2" with no variant | ||
|
||
# app fields | ||
And the event "unhandled" is false | ||
And the event "app.binaryArch" equals "x86" | ||
And the event "app.id" equals "12345" | ||
And the event "app.releaseStage" equals "custom" | ||
And the event "app.version" equals "1.2.3" | ||
And the event "app.buildUUID" equals "12345678" | ||
And the event "app.type" equals "android_custom" | ||
And the event "app.versionCode" equals 123 | ||
And the event "app.duration" equals 123456 | ||
And the event "app.durationInForeground" equals 123456 | ||
And the event "app.inForeground" is false | ||
And the event "app.isLaunching" is false | ||
|
||
# device fields | ||
And the event "device.id" equals "12345" | ||
And the event "device.jailbroken" is true | ||
And the event "device.locale" equals "en-UK" | ||
And the event "device.totalMemory" equals 123456 | ||
And the event "device.runtimeVersions.androidApiLevel" equals "30" | ||
And the event "device.freeDisk" equals 123456 | ||
And the event "device.freeMemory" equals 123456 | ||
And the event "device.orientation" equals "portrait" | ||
|
||
# breadcrumbs fields | ||
And the event "breadcrumbs.0.type" equals "error" | ||
And the event "breadcrumbs.0.name" equals "new breadcrumb message" | ||
And the event "breadcrumbs.0.metaData.foo" equals "data" | ||
And the event "breadcrumbs.1.type" equals "error" | ||
And the event "breadcrumbs.1.name" equals "Second breadcrumb message" |