-
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.
test: add E2E tests for autoNotify/autoDetectAnrs
- Loading branch information
1 parent
458a9b5
commit a27c2af
Showing
11 changed files
with
275 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
30 changes: 30 additions & 0 deletions
30
...main/java/com/bugsnag/android/mazerunner/scenarios/UnhandledNdkAutoNotifyFalseScenario.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,30 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.getZeroEventsLogMessages | ||
import com.bugsnag.android.setAutoNotify | ||
|
||
class UnhandledNdkAutoNotifyFalseScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
init { | ||
System.loadLibrary("cxx-scenarios") | ||
} | ||
|
||
external fun crash() | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoNotify(Bugsnag.getClient(), false) | ||
crash() | ||
} | ||
|
||
override fun getInterceptedLogMessages(): List<String> { | ||
return getZeroEventsLogMessages(startBugsnagOnly) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../main/java/com/bugsnag/android/mazerunner/scenarios/UnhandledNdkAutoNotifyTrueScenario.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,26 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.setAutoNotify | ||
|
||
class UnhandledNdkAutoNotifyTrueScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
init { | ||
System.loadLibrary("cxx-scenarios") | ||
} | ||
|
||
external fun crash() | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoNotify(Bugsnag.getClient(), false) | ||
setAutoNotify(Bugsnag.getClient(), true) | ||
crash() | ||
} | ||
} |
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
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
37 changes: 37 additions & 0 deletions
37
...ios/src/main/java/com/bugsnag/android/mazerunner/scenarios/AutoDetectAnrsFalseScenario.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,37 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import android.os.Handler | ||
import android.os.Looper | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.getZeroEventsLogMessages | ||
import com.bugsnag.android.setAutoDetectAnrs | ||
|
||
internal class AutoDetectAnrsFalseScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
init { | ||
config.enabledErrorTypes.anrs = true | ||
} | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoDetectAnrs(Bugsnag.getClient(), false) | ||
|
||
val main = Handler(Looper.getMainLooper()) | ||
main.postDelayed( | ||
Runnable { | ||
Thread.sleep(100000) | ||
}, | ||
1 | ||
) // A moment of delay so there is something to 'tap' onscreen | ||
} | ||
|
||
override fun getInterceptedLogMessages(): List<String> { | ||
return getZeroEventsLogMessages(startBugsnagOnly) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...rios/src/main/java/com/bugsnag/android/mazerunner/scenarios/AutoDetectAnrsTrueScenario.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,33 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import android.os.Handler | ||
import android.os.Looper | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.setAutoDetectAnrs | ||
|
||
internal class AutoDetectAnrsTrueScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
init { | ||
config.enabledErrorTypes.anrs = true | ||
} | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoDetectAnrs(Bugsnag.getClient(), false) | ||
setAutoDetectAnrs(Bugsnag.getClient(), true) | ||
|
||
val main = Handler(Looper.getMainLooper()) | ||
main.postDelayed( | ||
Runnable { | ||
Thread.sleep(100000) | ||
}, | ||
1 | ||
) // A moment of delay so there is something to 'tap' onscreen | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...c/main/java/com/bugsnag/android/mazerunner/scenarios/HandledJvmAutoNotifyFalseScenario.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,19 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.setAutoNotify | ||
|
||
class HandledJvmAutoNotifyFalseScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoNotify(Bugsnag.getClient(), false) | ||
Bugsnag.notify(generateException()) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...main/java/com/bugsnag/android/mazerunner/scenarios/UnhandledJvmAutoNotifyFalseScenario.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,24 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.getZeroEventsLogMessages | ||
import com.bugsnag.android.setAutoNotify | ||
|
||
class UnhandledJvmAutoNotifyFalseScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoNotify(Bugsnag.getClient(), false) | ||
throw generateException() | ||
} | ||
|
||
override fun getInterceptedLogMessages(): List<String> { | ||
return getZeroEventsLogMessages(startBugsnagOnly) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../main/java/com/bugsnag/android/mazerunner/scenarios/UnhandledJvmAutoNotifyTrueScenario.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 | ||
import com.bugsnag.android.setAutoNotify | ||
|
||
class UnhandledJvmAutoNotifyTrueScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
|
||
override fun startScenario() { | ||
super.startScenario() | ||
setAutoNotify(Bugsnag.getClient(), false) | ||
setAutoNotify(Bugsnag.getClient(), true) | ||
throw generateException() | ||
} | ||
} |
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,66 @@ | ||
Feature: Switching automatic error detection on/off for Unity | ||
|
||
Scenario: Handled JVM exceptions are captured with autoNotify=false | ||
When I run "HandledJvmAutoNotifyFalseScenario" | ||
Then I wait to receive an error | ||
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier | ||
And the exception "message" equals "HandledJvmAutoNotifyFalseScenario" | ||
|
||
Scenario: JVM exception not captured with autoNotify=false | ||
When I run "UnhandledJvmAutoNotifyFalseScenario" and relaunch the app | ||
And I configure Bugsnag for "UnhandledJvmAutoNotifyFalseScenario" | ||
Then Bugsnag confirms it has no errors to send | ||
|
||
Scenario: NDK signal not captured with autoNotify=false | ||
When I run "UnhandledNdkAutoNotifyFalseScenario" and relaunch the app | ||
And I configure Bugsnag for "UnhandledNdkAutoNotifyFalseScenario" | ||
Then Bugsnag confirms it has no errors to send | ||
|
||
@skip_android_8_1 | ||
Scenario: ANR not captured with autoDetectAnrs=false | ||
When I run "AutoDetectAnrsFalseScenario" and relaunch the app | ||
And I configure Bugsnag for "AutoDetectAnrsFalseScenario" | ||
Then Bugsnag confirms it has no errors to send | ||
|
||
Scenario: JVM exception captured with autoNotify reenabled | ||
When I run "UnhandledJvmAutoNotifyTrueScenario" and relaunch the app | ||
And I configure Bugsnag for "UnhandledJvmAutoNotifyTrueScenario" | ||
Then I wait to receive an error | ||
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier | ||
And the error payload field "events" is an array with 1 elements | ||
And the exception "errorClass" equals "java.lang.RuntimeException" | ||
And the exception "message" equals "UnhandledJvmAutoNotifyTrueScenario" | ||
And the exception "type" equals "android" | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
|
||
Scenario: NDK signal captured with autoNotify reenabled | ||
When I run "UnhandledNdkAutoNotifyTrueScenario" and relaunch the app | ||
And I configure Bugsnag for "UnhandledNdkAutoNotifyTrueScenario" | ||
Then I wait to receive an error | ||
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier | ||
And the error payload field "events" is an array with 1 elements | ||
And the exception "message" equals "Abort program" | ||
And the exception "type" equals "c" | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
And the event "severityReason.type" equals "signal" | ||
And the event "severityReason.unhandledOverridden" is false | ||
|
||
@skip_android_8_1 | ||
Scenario: ANR captured with autoDetectAnrs reenabled | ||
When I run "AutoDetectAnrsTrueScenario" | ||
And I wait for 2 seconds | ||
And I tap the screen 3 times | ||
And I wait for 4 seconds | ||
And I clear any error dialogue | ||
And I wait to receive an error | ||
Then the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier | ||
And the error payload field "events" is an array with 1 elements | ||
And the exception "errorClass" equals "ANR" | ||
And the exception "message" starts with " Input dispatching timed out" | ||
And the exception "type" equals "android" | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
And the event "severityReason.type" equals "anrError" | ||
And the event "severityReason.unhandledOverridden" is false |