-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mazerunner scenarios for stopping/resuming a session #430
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19a2ef9
test: add mazerunner scenarios for stopping/resuming a session
fractalwrench 62954c7
tests: Update locked version of maze-runner
Cawllec f3ec09a
tests: Add session id & time comparison to stoppedSessions
Cawllec 9988dc5
tests: Add new session scenario to session_stopping feature
Cawllec 8c90a00
tests: Fix tests comment
Cawllec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...zerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/ResumedSessionScenario.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,35 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import android.os.Handler | ||
import android.os.HandlerThread | ||
|
||
/** | ||
* Sends 2 exceptions, 1 before resuming a session, and 1 after resuming a session. | ||
*/ | ||
internal class ResumedSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
init { | ||
config.setAutoCaptureSessions(false) | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
val client = Bugsnag.getClient() | ||
val thread = HandlerThread("HandlerThread") | ||
thread.start() | ||
|
||
Handler(thread.looper).post { | ||
// send 1st exception | ||
client.startSession() | ||
client.notifyBlocking(generateException()) | ||
|
||
// send 2nd exception after resuming a session | ||
client.stopSession() | ||
client.resumeSession() | ||
client.notifyBlocking(generateException()) | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...zerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/StoppedSessionScenario.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,34 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import android.os.Handler | ||
import android.os.HandlerThread | ||
|
||
/** | ||
* Sends an exception after stopping the session | ||
*/ | ||
internal class StoppedSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
init { | ||
config.setAutoCaptureSessions(false) | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
val client = Bugsnag.getClient() | ||
val thread = HandlerThread("HandlerThread") | ||
thread.start() | ||
|
||
Handler(thread.looper).post { | ||
// send 1st exception which should include session info | ||
client.startSession() | ||
client.notifyBlocking(generateException()) | ||
|
||
// send 2nd exception which should not include session info | ||
client.stopSession() | ||
client.notifyBlocking(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,19 @@ | ||
Feature: Stopping and resuming sessions | ||
|
||
Scenario: When a session is stopped the error has no session information | ||
When I run "StoppedSessionScenario" | ||
Then I should receive 3 requests | ||
And the request 0 is valid for the session tracking API | ||
And the request 1 is valid for the error reporting API | ||
And the request 2 is valid for the error reporting API | ||
And the payload field "events.0.session" is not null for request 1 | ||
And the payload field "events.0.session" is null for request 2 | ||
|
||
Scenario: When a session is resumed the error uses the previous session information | ||
When I run "ResumedSessionScenario" | ||
Then I should receive 3 requests | ||
And the request 0 is valid for the session tracking API | ||
And the request 1 is valid for the error reporting API | ||
And the request 2 is valid for the error reporting API | ||
And the payload field "events.0.session.events.handled" equals 1 for request 1 | ||
And the payload field "events.0.session.events.handled" equals 2 for request 2 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to add a comparison between UUID's and start times here