Skip to content

Commit 6503270

Browse files
committed
test(ErrorOptions): added a more complete e2e test suite for ErrorCaptureOptions
1 parent 4f7e775 commit 6503270

File tree

3 files changed

+104
-7
lines changed

3 files changed

+104
-7
lines changed

features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/ErrorOptionsScenario.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@ class ErrorOptionsScenario(
1313
) : Scenario(config, context, eventMetadata) {
1414
private val errorOptions = ErrorOptions(ErrorCaptureOptions.captureNothing())
1515

16+
init {
17+
val enabledCapture = eventMetadata?.splitToSequence(' ')
18+
?.map { it.trim() }
19+
?.toMutableSet()
20+
?: mutableSetOf()
21+
22+
// remove each of the options - if they were present set the associated capture option
23+
errorOptions.capture.stacktrace = enabledCapture.remove("stacktrace")
24+
errorOptions.capture.breadcrumbs = enabledCapture.remove("breadcrumbs")
25+
errorOptions.capture.featureFlags = enabledCapture.remove("featureFlags")
26+
errorOptions.capture.threads = enabledCapture.remove("threads")
27+
errorOptions.capture.user = enabledCapture.remove("user")
28+
29+
// any remaining options are used for metadata tabs
30+
errorOptions.capture.metadata = enabledCapture
31+
}
32+
1633
override fun startScenario() {
1734
super.startScenario()
18-
Bugsnag.addMetadata("custom", "key", "value")
35+
Bugsnag.addMetadata("custom", "key1", "value")
36+
Bugsnag.addMetadata("custom2", "testKey2", "value")
1937
Bugsnag.leaveBreadcrumb("Test breadcrumb")
2038
Bugsnag.addFeatureFlag("testFeatureFlag", "variantA")
39+
Bugsnag.addFeatureFlag("featureFlag2")
2140
Bugsnag.setUser("123", "jane@doe.com", "Jane Doe")
22-
Bugsnag.notify(generateException(), errorOptions, null)
41+
Bugsnag.notify(generateException(), errorOptions)
2342
}
2443
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Feature: ErrorCaptureOptions
2+
3+
Background:
4+
Given I clear all persistent data
5+
6+
Scenario: Capture only stacktrace
7+
When I configure the app to run in the "stacktrace" state
8+
And I run "ErrorOptionsScenario"
9+
Then I wait to receive an error
10+
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
11+
# Stacktrace validation
12+
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
13+
And the event "exceptions.0.stacktrace.0.method" ends with "ErrorOptionsScenario.startScenario"
14+
And the exception "stacktrace.0.file" equals "SourceFile"
15+
16+
And the event "user.id" is null
17+
And the event "user.name" is null
18+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
19+
And the error payload field "events.0.featureFlags" is an array with 0 elements
20+
And the error payload field "events.0.threads" is an array with 0 elements
21+
22+
Scenario: Capture only user
23+
When I configure the app to run in the "user" state
24+
And I run "ErrorOptionsScenario"
25+
Then I wait to receive an error
26+
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
27+
28+
And the event "user.id" equals "123"
29+
And the event "user.email" equals "jane@doe.com"
30+
And the event "user.name" equals "Jane Doe"
31+
32+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
33+
And the error payload field "events.0.featureFlags" is an array with 0 elements
34+
And the error payload field "events.0.threads" is an array with 0 elements
35+
36+
Scenario: Capture only breadcrumbs
37+
When I configure the app to run in the "breadcrumbs" state
38+
And I run "ErrorOptionsScenario"
39+
Then I wait to receive an error
40+
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
41+
42+
And the event "user.id" equals "123"
43+
And the event "user.email" equals "jane@doe.com"
44+
And the event "user.name" equals "Jane Doe"
45+
46+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
47+
And the error payload field "events.0.featureFlags" is an array with 0 elements
48+
And the error payload field "events.0.threads" is an array with 0 elements
49+
50+
Scenario: Capture only feature flags
51+
When I configure the app to run in the "user" state
52+
And I run "ErrorOptionsScenario"
53+
Then I wait to receive an error
54+
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
55+
And the event "user.id" is null
56+
And the event "user.name" is null
57+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
58+
And the error payload field "events.0.threads" is an array with 0 elements
59+
60+
And the error payload field "events.0.featureFlags" is an array with 2 elements
61+
And event 0 contains the feature flag "testFeatureFlag" with variant "variantA"
62+
And event 0 contains the feature flag "featureFlag2" with no variant
63+
64+
Scenario: Capture selected metadata and stacktrace
65+
When I configure the app to run in the "custom2" state
66+
And I run "ErrorOptionsScenario"
67+
Then I wait to receive an error
68+
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
69+
# Stacktrace validation
70+
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
71+
And the event "exceptions.0.stacktrace.0.method" ends with "ErrorOptionsScenario.startScenario"
72+
And the exception "stacktrace.0.file" equals "SourceFile"
73+
74+
And the event "user.id" is null
75+
And the event "user.name" is null
76+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
77+
And the error payload field "events.0.featureFlags" is an array with 0 elements
78+
And the event "metaData.custom2.testKey2" equals "value"

features/smoke_tests/02_handled.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ Feature: Handled smoke tests
250250
And the event "threads.0.stacktrace.0.file" is not null
251251
And the event "threads.0.stacktrace.0.lineNumber" is not null
252252

253-
Scenario: Handled exceptions with negative options
253+
Scenario: Handled exceptions with captureNone options
254254
When I run "ErrorOptionsScenario"
255255
Then I wait to receive an error
256256
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
257257
And the event "stacktrace" is null
258-
And the event "breadcrumbs.0" is null
259-
And the event "featureFlags.0" is null
260-
And the event "threads.0" is null
261258
And the event "user.id" is null
262-
And the event "user.name" is null
259+
And the event "user.name" is null
260+
And the error payload field "events.0.breadcrumbs" is an array with 0 elements
261+
And the error payload field "events.0.featureFlags" is an array with 0 elements
262+
And the error payload field "events.0.threads" is an array with 0 elements

0 commit comments

Comments
 (0)