-
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.
update test scenarios to include auto session tracking, rework how bu…
…gsnag is initialised to allow greater configurability from test harness
- Loading branch information
1 parent
2634763
commit 2c60c8f
Showing
10 changed files
with
80 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Feature: Android support | ||
|
||
Scenario: Automatic Session Tracking | ||
When I run "AutoSessionScenario" with the defaults | ||
And I wait for 1 seconds | ||
Then I should receive a request | ||
And the request is a valid for the session tracking API | ||
And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" | ||
And the payload field "notifier.name" equals "Android Bugsnag Notifier" | ||
And the payload field "sessions" is an array with 1 element | ||
And the session "user.id" equals "123" | ||
And the session "user.email" equals "user@example.com" | ||
And the session "user.name" equals "Joe Bloggs" | ||
And the session "id" is not null | ||
And the session "startedAt" is not null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
</intent-filter> | ||
</activity> | ||
<activity android:name=".SecondActivity"/> | ||
</application> | ||
|
||
</manifest> |
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
13 changes: 13 additions & 0 deletions
13
mazerunner/src/main/java/com/bugsnag/android/mazerunner/SecondActivity.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,13 @@ | ||
package com.bugsnag.android.mazerunner | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
|
||
class SecondActivity : Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
} | ||
|
||
} |
7 changes: 5 additions & 2 deletions
7
mazerunner/src/main/java/com/bugsnag/android/mazerunner/TestCaseFactory.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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package com.bugsnag.android.mazerunner | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.mazerunner.scenarios.Scenario | ||
|
||
internal class TestCaseFactory { | ||
|
||
fun testCaseForName(eventType: String?): Scenario { | ||
fun testCaseForName(eventType: String?, config: Configuration, context: Context): Scenario { | ||
val clz = Class.forName("com.bugsnag.android.mazerunner.scenarios.$eventType") | ||
return clz.newInstance() as Scenario | ||
val constructor = clz.constructors[0] | ||
return constructor.newInstance(config, context) as Scenario | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/AutoSessionScenario.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 android.content.Intent | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.flushAllSessions | ||
import com.bugsnag.android.mazerunner.SecondActivity | ||
|
||
/** | ||
* Sends a manual session payload to Bugsnag. | ||
*/ | ||
internal class AutoSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
config.setAutoCaptureSessions(true) | ||
super.run() | ||
Bugsnag.setUser("123", "user@example.com", "Joe Bloggs") | ||
context.startActivity(Intent(context, SecondActivity::class.java)) | ||
flushAllSessions() | ||
} | ||
|
||
} |
6 changes: 5 additions & 1 deletion
6
...runner/src/main/java/com/bugsnag/android/mazerunner/scenarios/HandledExceptionScenario.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
6 changes: 5 additions & 1 deletion
6
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualSessionScenario.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
10 changes: 8 additions & 2 deletions
10
mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/Scenario.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