Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
grafite.pdf
Search
Santosh Astagi
August 15, 2018
Technology
0
290
grafite.pdf
Using Gradle, Firebase Testlab for Android testing.
Santosh Astagi
August 15, 2018
Tweet
Share
Other Decks in Technology
See All in Technology
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
OpenShift Virtualizationのネットワーク構成を真剣に考えてみた/OpenShift Virtualization's Network Configuration
tnk4on
0
130
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
24
11k
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.2k
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
110
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
120
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
It's Worth the Effort
3n
183
28k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
A better future with KSS
kneath
238
17k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Site-Speed That Sticks
csswizardry
2
190
Automating Front-end Workflow
addyosmani
1366
200k
GraphQLとの向き合い方2022年版
quramy
44
13k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
Gra-Fi-Te Leveraging Gradle and Firebase for Android Testing Santosh Astagi
Rally Health
Gradlew wrapper - ./gradlew
Gradle tasks - ./gradlew tasks
Android plugin for gradle - com.android.tools.build:gradle:#.#.# Android tasks Build tasks
Install tasks Verification tasks - Testing tasks
Unit tests - test Running all tests - ./gradlew test
Running all tests for a flavor - ./gradlew test{flavor}UnitTest Running individual tests - ./gradlew test{flavor}UnitTest\ —tests {packageName}.{testMethodName} Wild cards - ./gradlew test{flavor}UnitTest\ —tests *includedTestTitle*
Instrumentation tests - androidTest Running all tests - ./gradlew connectedAndroidTest
OR cAT Running a specific test - ./gradlew connectedAndroidTest\ -Pandroid.testInstrumentationRunnerArguments.class\ ={package name}.{class name}#{method name} GOTCHA - testCoverage, orchestrator:1.0.2 with gradle plugin <3.2 android plugin - 3.3.0+, gradle version - 4.9
Filtering tests - Annotations @SmallTest - < 100ms, unit tests
./gradlew connectedAndroidTest\ -Pandroid.testInstrumentationRunnerArguments.size\ =Large @MediumTest - < 2s, every checkin, avoid blocking operations @LargeTest - <120s, Atleast once a day, all external communications
testOptions{} - Android Plugin DSL Reference Specify reportDir, resultsDir testBuildType
to change default from debug unitTests {…} (Possible additions below) includeAndroidResources true returnDefaultValues true
Coverage reports testCoverageEnabled true ./gradlew createDebugCoverageReport apply plugin: "jacoco" Coverage
report: jacoco/test{flavor}UnitTest.exec
Gradle tasks task taskname( ) { } Copy from "origin"
into "destination" Gradle DSL method not found: 'from()' type:
Gradle tasks task taskname( ) type: //Pre built task description:
//Meaningful enough dependsOn: //task to be executed before group: //E.g. verification, install ./gradlew taskName -PpropertyName=propertyValue project.hasProperty(“propertyName”) project.property(“propertyName”)
Unified reports task unifiedReport( type: JacocoReport, dependsOn: ['testDebugUnitTest'], ‘createDebugCoverageReport’] )
{ sourceDirectories = files(coverageSourceDirs) classDirectories = files([javaClasses], [kotlinClasses]) executionData = fileTree(dir: project.projectDir, includes: [“coverage.exec”, “testDebugUnitTest.exec”)
Unified reports task unifiedReport( type: JacocoReport, dependsOn: ['testDebugUnitTest'] ) {
} reports { xml.enabled = true html.enabled = true } /build/reports/jacoco/…
None
Robolectric tests coverage Prior 3.0 plugin, jacoco node in unitTests
block Search for tasks of type test tasks.withType(Test) { jacoco.includeNoLocationClasses = true } }
Kotlin data classes
Jacoco snapshot build https://oss.sonatype.org/content/repositories/snapshots project.jacoco { toolVersion = '0.8.2-SNAPSHOT' }
Multi module apps
app models networking ext.jacocoReport = {Project project, String variant ->
} jacocoReport(project, ‘debug’) jacocoReport(project, ‘debug’) jacocoReport(project, ‘debug’)
Gradle methods ext.jacocoTestReport = {Project project, String variant -> }
jacocoTestReport(project, ‘flavorName’) project.tasks.create( name: ‘jacocoTestReport’ ) { }
Combining reports apply plugin: ‘android-reporting’ ./gradlew connectedAndroidTest mergeAndroidReports {root project}/build/reports
./gradlew createDebugCoverageReport mergeAndroidReports
Unified reporting root level gradle task Update coverage directories using
$rootProject Update class directories using $rootProject /build/reports/jacoco/…
Cloud testing
Cloud testing Firebase testlab, Saucelabs, Genymotion, Amazon, Xamarin etc. Firebase
testlab beta for iOS announced at I/O 18 Firebase - wide range of devices and emulators
Testlab - options, useful configurations - -timeout - max. time
this execution can run (timeout code sent back) - - performance-metrics - CPU usage, network usage, FPS - - results-bucket - Specify gcloud bucket Specific exit codes to play nicely with scripts
Firebase console - using reports Stored in Google Cloud bucket
Contains more than just logs, views and performance, can get code coverage, results xml, full log
Firebase testlab - Running tests
Firebase - device options gcloud firebase test android models list
Firebase console - command line Type - robo, instrumentation, game-loop
gcloud firebase test android run --type instrumentation --app app/build/outputs/apk/debug/app-debug.apk --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk --devices-ids Nexus5 --os-version-ids 23 --locales en --orientations portrait --environment-variables coverage=true,coverageFile="/sdcard/coverage.ec"
Firebase testlab - Artifacts and fetching
Firebase - gcloud options Firebase test artifacts stores in Google
cloud buckets Install gsutil to get CLI to interact with bucket artifacts gsutil ls gs://testingplaygroundresults
Coverage reports Enable device storage in manifest --directories-to-pull /sdcard gsutil
cp gs://testingplaygroundresults/*/*/artifacts/ coverage.ec .
None
Test sharing through flank
Flank - Walmart Labs Scaling automated UI tests - Espresso
and Appium Throttling support Device config Test results downloaded to project root
Flank - Walmart Labs Test 1 Test 2 Test 3
Test 4 Test 5 Stores test times during first run Uses test times to distribute tests across devices https://github.com/TestArmada/flank
https://github.com/sastagi/grafite @sastagi Thank you