Skip to content

Commit

Permalink
test: update internal error report test to trigger error from corrupt…
Browse files Browse the repository at this point in the history
…ed json file
  • Loading branch information
fractalwrench committed Aug 23, 2019
1 parent 876e5b0 commit 1cce3bc
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
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 java.io.File

/**
* Verifies that if a report is empty, minimal information is still sent to bugsnag.
*/
internal class EmptyReportScenario(config: Configuration,
context: Context) : Scenario(config, context) {

init {
config.setAutoCaptureSessions(false)
val files = File(context.cacheDir, "bugsnag-errors").listFiles()
files.forEach { it.writeText("") }
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.bugsnag.android.mazerunner.scenarios

import android.content.Context
import com.bugsnag.android.*
import com.bugsnag.android.Bugsnag
import com.bugsnag.android.Configuration
import java.io.File

/**
* Sends a handled exception to Bugsnag, which does not include session data.
*/
internal class InternalReportScenario(config: Configuration,
context: Context) : Scenario(config, context) {

init {
config.setAutoCaptureSessions(false)
disableAllDelivery(config)
}

override fun run() {
super.run()
sendInternalReport(RuntimeException("Whoops"), config, Bugsnag.getClient())
Bugsnag.notify(java.lang.RuntimeException("Whoops"))
}

}
}
4 changes: 3 additions & 1 deletion features/internal_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ Feature: Sending internal error reports

Scenario: Send a report about an error triggered within the notifier
When I run "InternalReportScenario"
And I set environment variable "EVENT_TYPE" to "EmptyReportScenario"
And I relaunch the app
Then I should receive 1 request
And the "Bugsnag-Internal-Error" header equals "true"
And the payload field "apiKey" is null
And the event "context" is null
And the event "context" equals "Crash Report Deserialization"
And the event "session" is null
And the event "breadcrumbs" is null
And the event "app.type" equals "android"
Expand Down
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 java.io.File

/**
* Verifies that if a report is empty, minimal information is still sent to bugsnag.
*/
internal class EmptyReportScenario(config: Configuration,
context: Context) : Scenario(config, context) {

init {
config.setAutoCaptureSessions(false)
val files = File(context.cacheDir, "bugsnag-errors").listFiles()
files.forEach { it.writeText("") }
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.bugsnag.android.mazerunner.scenarios

import android.content.Context
import com.bugsnag.android.*
import com.bugsnag.android.Bugsnag
import com.bugsnag.android.Configuration
import java.io.File

/**
* Sends a handled exception to Bugsnag, which does not include session data.
*/
internal class InternalReportScenario(config: Configuration,
context: Context) : Scenario(config, context) {

init {
config.setAutoCaptureSessions(false)
disableAllDelivery(config)
}

override fun run() {
super.run()
sendInternalReport(RuntimeException("Whoops"), config, Bugsnag.getClient())
Bugsnag.notify(java.lang.RuntimeException("Whoops"))
}

}
}

0 comments on commit 1cce3bc

Please sign in to comment.