Skip to content

Instantly share code, notes, and snippets.

View chan-bo's full-sized avatar

Chanbo chan-bo

View GitHub Profile
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Allows for storing and retrieving screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
@RunWith(JUnit4::class)
class AutomateScreenshotsTest {
@Before
fun setUp() {
ActivityScenario.launch(MainActivity::class.java)
Screengrab.setDefaultScreenshotStrategry(UiAutomatorScreenshotStrategy())
}
@Test
@Before
fun setUp() {
ActivityScenario.launch(MainActivity::class.java)
Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy())
}
@Test
fun captureScreen() {
// Delay 500 millis for app launch to main screen
Thread.sleep(500)
Screengrab.screenshot("main_screen")
}
desc "Capture Screen"
lane :capture_screen do
gradle(task: "clean assembleDebug assembleAndroidTest")
screengrab
end
locales ['en-US']
clear_previous_screenshots true
tests_apk_path 'app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk'
app_apk_path 'app/build/outputs/apk/debug/app-debug.apk'
test_instrumentation_runner 'androidx.test.runner.AndroidJUnitRunner'
desc "Beta Deployment"
lane :beta do
# Adjust the `build_type` and `flavor` params as needed to build the right APK for your setup
gradle(
task: 'assemble',
build_type: 'Release'
)
crashlytics(
apk_path: ['insert_apk_path'],
api_token: ['insert_key_here'],
json_key_file "/path/to/your/downloaded/key.json"
desc "Deploy app to play store"
lane :deploy do
gradle(
task: 'assemble',
build_type: 'Release'
)
upload_to_play_store(track:'beta')
end