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
A good Barista to enjoy a good Espresso
Search
RubenAbad
October 16, 2018
Programming
0
33
A good Barista to enjoy a good Espresso
RubenAbad
October 16, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
Milestoner
bkuhlmann
1
410
使ってみよう Azure AI Document Intelligence
kosmosebi
2
290
データアナリストが行うDatabricksを活用したETLの自動化事例
shinoa
0
260
Ruby Pattern Matching
bkuhlmann
0
920
코틀린으로 멀티플랫폼 만들기
pangmoo
0
150
新宿ダンジョンを可視化してみた
satoshi7190
2
230
Elm Form Validation
bkuhlmann
0
510
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
480
Fragment Composition of GraphQL
quramy
2
160
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
190
雑に思考を整理する技術と効能
konifar
58
29k
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
940
Featured
See All Featured
How to name files
jennybc
65
93k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
120
39k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Producing Creativity
orderedlist
PRO
337
39k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
241
1.2M
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
4 Signs Your Business is Dying
shpigford
175
21k
How to Ace a Technical Interview
jacobian
272
22k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Transcript
Android Kaizen Talks Introducing Barista library
“The person who serves a great Espresso”
Espresso onView(withId(R.id.button)).perform(click()) Barista clickOn(R.id.button)
Interactions with Barista
clickOn(R.id.viewId) clickOn(R.string.some_text) clickOn(“Some text”) clickBack()
longClickOn(R.id.viewId) longClickOn(R.string.some_text) longClickOn(“Some text”) Long click?
writeTo(R.id.editTextId, “Cooooool stuff!”) clearText(R.id.editTextId)
Are you having troubles to test ListViews / RecyclerViews?
clickListItem(R.id.recyclerViewId, itemPosition) clickListItemChild( R.id.recyclerViewId, itemPosition, R.id.clickableViewId ) scrollListToPosition(R.id.recyclerViewId, itemPosition)
And more, and more useful functions… clickMenu(R.id.menuItemId) clickSpinnerItem(R.id.spinnerId, 2) openDrawer()
refresh() closeKeyboard() swipeViewPagerForward() …
Assertions with Barista
Espresso onView(withId(R.id.button)).check(isDisplayed()) Barista assertDisplayed(R.id.button)
assertDisplayed(R.id.buttonId) assertDisplayed(R.string.textId) assertDisplayed(“Displayed!”) assertDisplayed(R.id.buttonId, “Displayed!”)
assertDisplayed assertNotDisplayed assertEnabled assertDisabled assertNotExist assertChecked assertUnchecked assertHasAnyDrawable assertHasDrawable assertHasAnyBackground
assertDrawerIsOpen assertDrawerIsClosed assertContains assertNotContains
Need more goodies?
Custom assertions
assertAny<Button>( ) { it.enabled == true } R.id.buttonId “Button text”
Need more goodies?
mockAndroidCamera() // Creates a Bitmap on a camera provided URI
Need more goodies?
PermissionGranter.allowPermissionsIfNeeded( Manifest.permission.GET_ACCOUNTS )
Need more goodies?
PermissionGranter.allowPermissionsIfNeeded( Manifest.permission.GET_ACCOUNTS )
Need more goodies?
@get:Rule val clearPreferenceRule = ClearPreferenceRule() // Clear all app’s SharedPreferences
@get:Rule val clearDatabaseRule = ClearDatabaseRule() // Delete all tables from all the app’s SQLite Databases @get:Rule val clearFilesRule = ClearFilesRule() // Delete all files in getFilesDir() and getCacheDir()
Need more goodies?
@Test @AllowFlaky(attempts = 5) fun myTest() { … } @Test
@Repeat(times = 5) fun myTest() { … }
Can it be even simpler by default?
@get:Rule val baristaRule = BaristaRule.create(MyActivity::class.java) baristaRule.launchActivity() //…
The rule assumes some sane defaults: - Retry flaky tests:
10 attempts - Launch activity automatically: false - Initial touch mode enabled: true - Clear preferences - Clear databases - Clear files
“Magic” that Barista does for you
- Scrolls when needed - Scrolls on all views, including
NestedScrollViews - Just interacts with displayed Views
Any question?
You can find everything you need at their Github! https://github.com/SchibstedSpain/Barista