-
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.
Merge pull request #1523 from bugsnag/PLAT-7611/onsend-mazerunner-tests
Mazerunner test for the OnSend callback
- Loading branch information
Showing
4 changed files
with
51 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
15 changes: 15 additions & 0 deletions
15
...xtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/TestOnSendCallback.java
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,15 @@ | ||
package com.bugsnag.android; | ||
|
||
import java.util.Collections; | ||
|
||
public class TestOnSendCallback implements OnSendCallback { | ||
@Override | ||
public boolean onSend(Event event) { | ||
event.addMetadata("mazerunner", Collections.singletonMap("onSendCallback", "true")); | ||
return true; | ||
} | ||
|
||
public void register(Configuration config) { | ||
config.addOnSend(this); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...cenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/OnSendCallbackScenario.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,25 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.TestOnSendCallback | ||
import java.lang.RuntimeException | ||
|
||
internal class OnSendCallbackScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String | ||
) : Scenario(config, context, eventMetadata) { | ||
override fun startBugsnag(startBugsnagOnly: Boolean) { | ||
TestOnSendCallback().register(config) | ||
super.startBugsnag(startBugsnagOnly) | ||
} | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
|
||
if (eventMetadata != "start-only") { | ||
throw RuntimeException("Unhandled Error") | ||
} | ||
} | ||
} |
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,10 @@ | ||
Feature: OnSend Callbacks can alter Events before upload | ||
|
||
Scenario: Handled exception with altered by OnSendCallback | ||
When I run "OnSendCallbackScenario" and relaunch the app | ||
And I configure the app to run in the "start-only" state | ||
And I configure Bugsnag for "OnSendCallbackScenario" | ||
Then I wait to receive an error | ||
And the error payload field "events" is an array with 1 elements | ||
And the exception "message" equals "Unhandled Error" | ||
And the event "metaData.mazerunner.onSendCallback" equals "true" |