-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
Integration testing for the sentry-native new unwinder #1371
Changes from all commits
4b1abd0
6c787d0
ce35ab6
404d872
ef56bbe
036eb77
90b8a14
9393162
1c2fa29
e6ee342
68a5230
ff96e9f
a900ab9
6d0cd79
1120bbd
10fe680
bcd8224
5ec4f9b
f75fbb6
b323c14
cfa3853
af7f1df
132ffe0
cc4f6d1
f223c8e
e1ef03a
513f098
539f44d
a850fbf
c9b95c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
sentry-samples-android-keystore | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we call this into https://github.com/getsentry/sentry-java/blob/main/Makefile somehow? |
||
|
||
# Usage | ||
# ./appcenter androidBuildToolsVersion keyAlias keyPass appCenterApp appCenterDevice | ||
# Sample | ||
# ./appcenter 29.0.3 keyAlias keyPass denrase/Sentry-Android-Sample e669fa3b # Nexus 5 Andorid 11 | ||
|
||
# Create Debug APK | ||
|
||
../../gradlew :sentry-samples:sentry-samples-android:clean | ||
../../gradlew :sentry-samples:sentry-samples-android:assembleDebug | ||
|
||
# Run Tests so Test APK is Built | ||
|
||
../../gradlew :sentry-samples:sentry-samples-android:connectedAndroidTest | ||
|
||
# Sign APK | ||
|
||
~/Library/Android/sdk/build-tools/$1/apksigner sign --ks sentry-samples-android-keystore --ks-pass pass:$2 --key-pass pass:$3 --in build/outputs/apk/debug/sentry-samples-android-debug.apk --out build/outputs/apk/debug/sentry-samples-android-debug.apk | ||
|
||
# Sign Test APK | ||
|
||
~/Library/Android/sdk/build-tools/$1/apksigner sign --ks sentry-samples-android-keystore --ks-pass pass:$2 --key-pass pass:$3 --in build/outputs/apk/androidTest/debug/sentry-samples-android-debug-androidTest.apk --out build/outputs/apk/androidTest/debug/sentry-samples-android-debug-androidTest.apk | ||
|
||
# Upload to AppCenter | ||
|
||
appcenter test run espresso --app "$4" --devices $5 --app-path build/outputs/apk/debug/sentry-samples-android-debug.apk --test-series "master" --locale "en_US" --build-dir build/outputs/apk/androidTest/debug |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package io.sentry.samples.android | ||
|
||
import android.support.test.uiautomator.UiDevice | ||
import android.support.test.uiautomator.UiSelector | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.action.ViewActions.scrollTo | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.microsoft.appcenter.espresso.Factory | ||
import com.microsoft.appcenter.espresso.ReportHelper | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class MainActivityTest { | ||
|
||
@get:Rule | ||
var activityRule: ActivityScenarioRule<MainActivity> | ||
= ActivityScenarioRule(MainActivity::class.java) | ||
|
||
@get:Rule | ||
val reportHelper: ReportHelper = Factory.getReportHelper() | ||
|
||
// Tests are run in alphabetical order... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to be sure that they don't run in parallel |
||
|
||
// We crash in a service to test if an envelope was created. | ||
@Test | ||
fun a_initSdkAndCrash() { | ||
reportHelper.label("initSdkAndCrash") | ||
onView(withId(R.id.native_crash)).perform(scrollTo(), click()) | ||
Thread.sleep(10000) | ||
|
||
// Close either app or android dialog | ||
|
||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
val okButton = mDevice.findObject(UiSelector().text("OK")) | ||
val closeAppButton = mDevice.findObject(UiSelector().text("Close app")) | ||
val allowButton = mDevice.findObject(UiSelector().text("OK")) | ||
when { | ||
okButton.exists() -> { | ||
okButton.click() | ||
} | ||
closeAppButton.exists() -> { | ||
closeAppButton.click() | ||
} | ||
allowButton.exists() -> { | ||
allowButton.click() | ||
} | ||
else -> { | ||
mDevice.pressBack() | ||
} | ||
} | ||
} | ||
|
||
// Check if envelope file is here. | ||
@Test | ||
fun b_checkIfFileExists() { | ||
|
||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
val okButton = mDevice.findObject(UiSelector().text("OK")) | ||
val closeAppButton = mDevice.findObject(UiSelector().text("Close app")) | ||
val allowButton = mDevice.findObject(UiSelector().text("OK")) | ||
when { | ||
okButton.exists() -> { | ||
okButton.click() | ||
} | ||
closeAppButton.exists() -> { | ||
closeAppButton.click() | ||
} | ||
allowButton.exists() -> { | ||
allowButton.click() | ||
} | ||
} | ||
|
||
onView(withId(R.id.button_copy_file)).perform(click()) | ||
onView(withId(R.id.text_view_copy_file)) | ||
.check(matches(withText("SUCCESS"))) | ||
|
||
reportHelper.label("checkIfFileExists") | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:theme="@style/AppTheme" | ||
android:allowNativeHeapPointerTagging="false" | ||
android:extractNativeLibs="true" | ||
tools:ignore="GoogleAppIndexingWarning, UnusedAttribute"> | ||
|
||
<activity android:name=".MainActivity"> | ||
|
@@ -35,9 +34,10 @@ | |
|
||
<activity android:name=".SecondActivity" /> | ||
|
||
<!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard--> | ||
<!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard--> | ||
<meta-data android:name="io.sentry.dsn" android:value="https://1053864c67cc410aa1ffc9701bd6f93d@o447951.ingest.sentry.io/5428559" /> | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<meta-data android:name="io.sentry.auto-init" android:value="false" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's create a new sample instead of using sentry-samples-android, otherwise, the current sample is totally broken |
||
<!-- how to enable Sentry's debug mode--> | ||
<meta-data android:name="io.sentry.debug" android:value="${sentryDebug}" /> | ||
|
||
|
@@ -101,5 +101,10 @@ | |
<!-- how to disable the app components breadcrumbs integration--> | ||
<!-- <meta-data android:name="io.sentry.breadcrumbs.app-components" android:value="false" />--> | ||
|
||
<service | ||
android:name=".NativeCrashService" | ||
android:process=":externalProcess"> | ||
</service> | ||
|
||
</application> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.sentry.samples.android | ||
|
||
import android.app.Service | ||
import android.content.Intent | ||
import android.os.Handler | ||
import android.os.IBinder | ||
import android.os.Looper | ||
import android.util.Log | ||
import io.sentry.android.core.SentryAndroid | ||
import java.io.File | ||
|
||
class NativeCrashService : Service() { | ||
|
||
override fun onBind(p0: Intent?): IBinder? { | ||
return null | ||
} | ||
|
||
override fun onStart(intent: Intent?, startId: Int) { | ||
handleStart() | ||
} | ||
|
||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
handleStart() | ||
return START_NOT_STICKY | ||
} | ||
|
||
private fun handleStart() { | ||
SentryAndroid.init(this) { | ||
// | ||
} | ||
|
||
// Dispatch async so method, and therefore START_NOT_STICKY, can return. | ||
val handler = Handler() | ||
val mainHandler = Handler(Looper.getMainLooper()) | ||
mainHandler.post { | ||
handler.post { | ||
NativeSample.crash() | ||
} | ||
} | ||
} | ||
} |
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.
could use this one https://github.com/getsentry/sentry-java/blob/main/debug.keystore