SlideShare a Scribd company logo
Uncovering breaking changes
behind UI on mobile applications
HeadSpin
Senior Software Engineer, Device Automation
Hi✋
• Kazuaki Matsuo
• from ", GitHub: KazuCocoa, Twitter: @Kazu_cocoa
• HeadSpin
• Senior Software Engineer now, former was a test/QA engineer
• Maintain Appium project
Topics
• Case study:
• Combination of capturing HTTP requests over Appium scenarios
• Tips:
• Some tips for Appium
Test Target
App: Long running app
• Many historical code
• Multiple teams developed one app
• Automated test environment was not matured enough
• Both Android and iOS
Situation: Collecting user flow
• Tracking user behaviour is important
• evaluate efforts by features, campaigns, etc
• Should be reliable
• The data was wrong case happened after
releasing a new version
• Unreliable data
• Monitoring it, get rid of them from the
analytics
User events, flow
Open the app
Click the button
Go to the view
Events to track actions
{
“events”: [
{
“name”: “OpenAnAppFromLauncher”,
“time”: ”2019-06-09 13:39:04 +0900” # time series to track user actions
},
{ …. }
]
}
“Open an app”
Open an app
Detect the action
Open an app
Store the log on the app
Store the log
{
“events”: [
{
“name”: “OpenAnAppFromLauncher”,
“time”: ”2019-06-09 13:39:04 +0900”
}

]
}
Send the log to the server
Store the log
Send to the stored log
to server
UI and non-UI
• UI layer
• User actions
• non-UI layer
• Store the data into local
• Send it to servers
UI
no UI
“behind UI”
• Behind UI in this title means such non-
UI layer
• Event logs
• HTTP requests
• Too many event logs/few event logs
unexpectedly
Might break
non-UI layer cases
Android
• Android has two main component to build UIs
• Activity
• Base view
• Fragment
• Re-useable view component
Lifecycle: Activity & Fragment
Activity Fragment
Before they are active
Activity Fragment
Where we set logs?
Activity Fragment
Easy to mistake
• “Open”, from where?
• Open the app from icon
• Open the app from app history
• Open the app from notification bar
• Back button and go to the app view from another
app
• They would like to define user flow
• We must define them correctly
From App Icon?
• “Open”, from where?
• Open the app from icon
• Open the app from app history
• Open the app from notification bar
• Back button and go to the app view from another
app
• They would like to define user flow
• We must define them correctly
From App History?
• “Open”, from where?
• Open the app from icon
• Open the app from app history
• Open the app from notification bar
• Back button and go to the app view from another
app
• They would like to define user flow
• We must define them correctly
From App Notification Bar?
• “Open”, from where?
• Open the app from icon
• Open the app from app history
• Open the app from notification bar
• Back button and go to the app view from another
app
• They would like to define user flow
• We must define them correctly
From Back Button?
• “Open”, from where?
• Open the app from icon
• Open the app from app history
• Open the app from notification bar
• Back button and go to the app view from another
app
• They would like to define user flow
• We must define them correctly
Where we set logs, again
Activity Fragment
Fragment
• Fragment is re-usable component
• Unexpected usage:
• A developer put a log into a fragment, for view A
• Another developer uses the fragment in another view, for view B,
while a log defined in the fragment should not be reused on view B
• What happen if a user open the view A and B?
• The log event happens on both view A and view B
• The data will break since the log should be called only on view A
View A
View B
iOS
Change their implemented languages
• Developers change their implementation languages
• Objective-C -> Swift
• Re-write to Swift, the behaviour should not change
Both
Prototype, Implement more
• prototype/minimal implementation
• Evaluate the value
• It is worth
• Re-write/refactor/add new features
• Do not change logs to make the data
comparable
Various path to move views
View A
View B
View D
View C
User flow
View A
View B
View D
View C
Wrap up the issue behind UI
• Logging user flows
• Android has view lifecycle which is complicated
• New programming language has been published
• Developers rewrite/refactor their product code
• Long running code has history
• It is not easy to introduce new testable architecture
What I did
Solution
• Capture HTTP requests during test running by automation
• Proxy server tools: WireMock, http_proxy
• Can we prevent such breaks only human communication to make
sure the behaviour?
• Probably, sometimes we can, but we cannot almost time
• Against release modules (or the same configuration)
HTTP proxy server
• Need a proxy server to capture the requests
• We have some kind of ways to capture it
How to capture the network?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
How to capture the network?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
How to capture the network?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
How to capture the network?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
How to capture the network?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
Where?
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on the device
Reverse
proxy
Application
Servers
No proxy server
Change app endpoint and connect directly
Which way?
• We can choose various points to capture the request
• Which way was the most fit for us?
Some points
• Wanted to handle test environment in the test script
• Would have like to start from small implementation
• Less configuration in server side
Direct connect
WiFi
Proxy serverNo proxy settings
on the device
Change Proxy Setting
on Android device
Reverse
proxy
No proxy server
Application
Servers
Change app endpoint and connect directly
How to connect to the proxy server?
Proxy server
Change app endpoint and connect directly
Reverse
proxy
Application
Servers
• Change the endpoint with:
1.Build configuration (need rebuild)
2.Environment variables, process
arguments, intent arguments
3.Change the preference via helper
app like io.appium.settings
2nd way
Proxy server
Direct connect
Reverse
proxy
Application
Servers
• Change the endpoint with:
1.Build configuration (need rebuild)
2.Environment variables, process
arguments, intent arguments
3.Change the preference via helper
app like io.appium.settings
Test Communication flow
between the Appium client to servers
Proxy
server
Server
Driver
App
Test
target
Which parts are handled by Ruby
Proxy
server
Server
Driver
App
Test
target
Capture the http requests in proxy server
Proxy
server
Server
Driver
App
Test
target
Capture data
With Appium
• Appium can control building test environment outside the app with the
same script
• Appium’s test cycle is before running the app under test
• Leverage the system to iOS and Android
• Espresso is after onCreate, XCTest is after launching the app
• XCTest was not released when I started to try this issue (2016)
• Espresso did not work on our app then (test not found happened
frequently, then)
Basic Appium flow
Configure the device/the test app Run tests on the test device Remain apps/delete apps
Appium’s test lifecycle
Configure the device/the test app Run tests on the test device Remain apps/delete apps
def setup()
// call create session
end
def test_some_cases()
// processes
end
def teardown()
// quit
end
Can conducts tests
Keeping the session
Espresso/XCTest
Configure the device/the test app Run tests on the test device Remain apps/delete apps
Setup Test cases Teardown
Runner install the test
target before test scripts
Espresso
XCTest
XCTest/Espresso
• Below setup and test cases are called after finishing to install the test
app
class appiumConfTest: XCTestCase {
override func setUp() {
// simulator is already running
XCUIApplication().launch()
}
func testExample() {
}
}
@RunWith(AndroidJUnit4::class)
class ExampleMainActivityTest {
private val testWatcher = MyTestWatcher()
private val scenarioRule =
ActivityScenarioRule<MainActivity>(
MainActivity::class.java)
// AndroidTestRunner launch onCreate (for example)
@get:Rule val ruleChain =
RuleChain.outerRule(testWatcher)
.around(scenarioRule)
@Test
fun test() {
//...
}
}
XCTest Espresso
HTTP proxies
• WireMock: https://github.com/tomakehurst/wiremock
• Java
• http_proxy: https://github.com/KazuCocoa/http_proxy
• Elixir
WireMock/http_proxy
• Can control responses/requests as JSON format
• Very handy to launch them as standalone
{
“request”: {
“path”: “/request/path”,
“port”: 8080,
“method”: “GET”
},
“response”: {
“body”: “<html>hello world</html>“,
“cookies”: {},
“headers”: {
“Content-Type”: “text/html; charset=UTF-8",
“Server”: “GFE/2.0"
},
“status_code”: 200
}
}
Integrate with Appium
• Launch proxy server before launching the test app
• Can configure test environment from test scripts
• Test lifecycle is greater than XCTest/Espresso
• Before installing test apps ~ after uninstalling them
Test suite
Configure the device
the test app
Run tests
on the test device
Remain apps
delete apps
def setup()
// call create session
end
def test_some_cases()
// processes
end
def teardown()
// quit
end
Start Stop
Analyse
the data
Summarise
test results
Proxy
Assert the captured data
• Count the number of HTTP requests
• Parse the JSON body and make sure the logs
• If something happens, the Ruby script raises failure
Summary
• Test lifecycle on Appium
• Getting HTTP requests via a proxy server
• How I implemented the capturing data behind UI
Tips
2nd way
Proxy server
Direct connect
Reverse
proxy
Application
Servers
• Change the endpoint with:
1.Build configuration (need rebuild)
2.Environment variables, process
arguments, intent arguments
3.Change the preference via helper
app like io.appium.settings
Process arguments
• XCTest framework provides
environment arguments for
xcodebuild argument
• An app can handle it as
env[“PROCESS_VALUE"] in the
app
• The environment works only
for the process
{
platformName: :ios,
automationName: 'XCUITest',
...
processArguments: {
env: {
"PROCESS_VALUE": "process value"
}
}
}
Packages, instrument args
• Android case
• We can make the release
app debug mode with:
• Launch an activity with
the arguments (adb
command)
• Install a particular
package name
{
platformName: :android,
automationName: 'uiautomator2',
...
optionalIntentArguments: '--ez key_name true’,
}
Package name:
com.example.randome_package_names
Simulating push notification, launch via history
• When we would like to emulate background to foreground
• Launch the all without auto launch
• Launch the app with broadcast receiver
• partially, we can emulate
• suspend/back
• Start activity with process arguments
One more thing
One more
• HTTP request is not the only thing which happens behind the UI
• CPU power etc
• Recently, we can see “performance measurement feature” by Google and Apple to capture them in particular
period
• https://developers.google.com/web/fundamentals/performance/rail
• This is mainly for Web, but this kind of performance should be same as mobile
• XCTMetric, benchmark etc
• https://github.com/KazuCocoa/droid-monitor
• Easy to collect data by Android via add/linux commands
• Nowadays, HeadSpin can do more rich thing tho…
• HeadSpin (company, service)
Takeaways
Takeaways
• Happening behind UI is not easy to uncover, but they are also
important
• The benefit of Appium to configure test environment
• Some tips to control the test app condition via Appium capability
Thanks
email: kazu@headspin.io
Twitter: @Kazu_cocoa

More Related Content

What's hot (20)

PDF
Selenium Camp 2016 - Kiev, Ukraine
Justin Ison
 
PPTX
Mobile Test Automation at eBay
Dominik Dary
 
PDF
Finland Azure User Group #8 DevOps Mobile Client Releases
Okko Oulasvirta
 
PPTX
Mobile performance metrics and performance monitoring meetup 2017 05 10
Bitbar
 
PPTX
Appium solution
Nael Abd Eljawad
 
PDF
Advanced Appium Tips & Tricks with Jonathan Lipps
Perfecto by Perforce
 
PPTX
Mobile Automation with Appium
Manoj Kumar Kumar
 
PDF
Implementing Test Automation in Agile Projects
Dominik Dary
 
PPTX
Applied Testing Heuristics in the Context of eBay
Dominik Dary
 
PDF
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
Srijan Technologies
 
PDF
Android UI Testing with Appium
Luke Maung
 
PPTX
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Bitbar
 
PPTX
Android Test Automation – one year later
Dominik Dary
 
PDF
Awesome Test Automation Made Simple w/ Dave Haeffner
Sauce Labs
 
PPTX
Mobile WebDriver Selendroid
Dominik Dary
 
PPTX
Best Practices in Mobile CI (webinar)
Sauce Labs
 
PPT
Appium
Deepshikha Singh
 
PDF
Appurify process
Maya Wagoner
 
PPTX
Automation testing on ios platform using appium
Ambreen Khan
 
PDF
Getting started with appium
Pratik Patel
 
Selenium Camp 2016 - Kiev, Ukraine
Justin Ison
 
Mobile Test Automation at eBay
Dominik Dary
 
Finland Azure User Group #8 DevOps Mobile Client Releases
Okko Oulasvirta
 
Mobile performance metrics and performance monitoring meetup 2017 05 10
Bitbar
 
Appium solution
Nael Abd Eljawad
 
Advanced Appium Tips & Tricks with Jonathan Lipps
Perfecto by Perforce
 
Mobile Automation with Appium
Manoj Kumar Kumar
 
Implementing Test Automation in Agile Projects
Dominik Dary
 
Applied Testing Heuristics in the Context of eBay
Dominik Dary
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
Srijan Technologies
 
Android UI Testing with Appium
Luke Maung
 
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Bitbar
 
Android Test Automation – one year later
Dominik Dary
 
Awesome Test Automation Made Simple w/ Dave Haeffner
Sauce Labs
 
Mobile WebDriver Selendroid
Dominik Dary
 
Best Practices in Mobile CI (webinar)
Sauce Labs
 
Appurify process
Maya Wagoner
 
Automation testing on ios platform using appium
Ambreen Khan
 
Getting started with appium
Pratik Patel
 

Similar to Uncovering breaking changes behind UI on mobile applications (20)

PPTX
Appium Overview - by Daniel Puterman
Applitools
 
PDF
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Applitools
 
PDF
Appium workship, Mobile Web+Dev Conference
Isaac Murchie
 
PDF
Appium mobile web+dev conference
Isaac Murchie
 
PDF
Appium workshop technopark trivandrum
Syam Sasi
 
PPTX
Appium overview (Selenium Israel #2, Feb. 2014)
danielputerman
 
PDF
Appium understanding document
Akshay Pillay
 
PDF
Philip Shurpik "Architecting React Native app"
Fwdays
 
PDF
Selenium in the palm of your hand: Appium and automated mobile testing
Isaac Murchie
 
PPTX
Appium.pptx
SameerAlam82
 
PDF
Appium - Reality check on the world’s leading Open Source Framework for Mobil...
Asaf Saar
 
PPT
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 
PPTX
Appium testing api
b4usolution .
 
PDF
Appium Native Application Crawler
Justin Ison
 
PPTX
iOS and Android apps automation
Sridhar Ramakrishnan
 
PDF
Denys iaremenko - Automation for mobile applications: WHYs and HOWs.
Web Tech Fun
 
KEY
Automated ui testing
DavidReidy
 
PPTX
b4usolution_Appium Mobile Automation Testing Made Awesome
b4usolution .
 
PDF
How to Test Android and iOS Mobile Apps with Appium.pdf
kalichargn70th171
 
PPTX
Advanced Appium
Dan Cuellar
 
Appium Overview - by Daniel Puterman
Applitools
 
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Applitools
 
Appium workship, Mobile Web+Dev Conference
Isaac Murchie
 
Appium mobile web+dev conference
Isaac Murchie
 
Appium workshop technopark trivandrum
Syam Sasi
 
Appium overview (Selenium Israel #2, Feb. 2014)
danielputerman
 
Appium understanding document
Akshay Pillay
 
Philip Shurpik "Architecting React Native app"
Fwdays
 
Selenium in the palm of your hand: Appium and automated mobile testing
Isaac Murchie
 
Appium.pptx
SameerAlam82
 
Appium - Reality check on the world’s leading Open Source Framework for Mobil...
Asaf Saar
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 
Appium testing api
b4usolution .
 
Appium Native Application Crawler
Justin Ison
 
iOS and Android apps automation
Sridhar Ramakrishnan
 
Denys iaremenko - Automation for mobile applications: WHYs and HOWs.
Web Tech Fun
 
Automated ui testing
DavidReidy
 
b4usolution_Appium Mobile Automation Testing Made Awesome
b4usolution .
 
How to Test Android and iOS Mobile Apps with Appium.pdf
kalichargn70th171
 
Advanced Appium
Dan Cuellar
 
Ad

More from Kazuaki Matsuo (20)

PDF
2022-jasst-tohoku.pdf
Kazuaki Matsuo
 
PDF
Add new commands in appium 2.0
Kazuaki Matsuo
 
PDF
Manage appium dependencies with -appium-home in appium 2.0
Kazuaki Matsuo
 
PDF
20210616-career-example-at-icare
Kazuaki Matsuo
 
PDF
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
 
PDF
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Kazuaki Matsuo
 
PDF
Xcode 11におけるXCUITestの挙動
Kazuaki Matsuo
 
PDF
20191130 system-automation-conference
Kazuaki Matsuo
 
PDF
Start contributing to OSS projects on your way
Kazuaki Matsuo
 
PDF
Go ahead outside Japan
Kazuaki Matsuo
 
PDF
CookpadTechConf2018-(Mobile)TestAutomation
Kazuaki Matsuo
 
PDF
20171215 andoird-test-night
Kazuaki Matsuo
 
PDF
20170726 ios test_night_no
Kazuaki Matsuo
 
PDF
20170701 lets-step-into-the-oss-community
Kazuaki Matsuo
 
PDF
20170613 tech easy
Kazuaki Matsuo
 
PDF
20170529 clem kazuaki_matsuo
Kazuaki Matsuo
 
PDF
20150423 m3
Kazuaki Matsuo
 
PDF
20170302 tryswift tasting_tests
Kazuaki Matsuo
 
PDF
20161126 to ruby
Kazuaki Matsuo
 
PDF
20160914 te engineer
Kazuaki Matsuo
 
2022-jasst-tohoku.pdf
Kazuaki Matsuo
 
Add new commands in appium 2.0
Kazuaki Matsuo
 
Manage appium dependencies with -appium-home in appium 2.0
Kazuaki Matsuo
 
20210616-career-example-at-icare
Kazuaki Matsuo
 
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
 
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Kazuaki Matsuo
 
Xcode 11におけるXCUITestの挙動
Kazuaki Matsuo
 
20191130 system-automation-conference
Kazuaki Matsuo
 
Start contributing to OSS projects on your way
Kazuaki Matsuo
 
Go ahead outside Japan
Kazuaki Matsuo
 
CookpadTechConf2018-(Mobile)TestAutomation
Kazuaki Matsuo
 
20171215 andoird-test-night
Kazuaki Matsuo
 
20170726 ios test_night_no
Kazuaki Matsuo
 
20170701 lets-step-into-the-oss-community
Kazuaki Matsuo
 
20170613 tech easy
Kazuaki Matsuo
 
20170529 clem kazuaki_matsuo
Kazuaki Matsuo
 
20150423 m3
Kazuaki Matsuo
 
20170302 tryswift tasting_tests
Kazuaki Matsuo
 
20161126 to ruby
Kazuaki Matsuo
 
20160914 te engineer
Kazuaki Matsuo
 
Ad

Recently uploaded (20)

PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Tally software_Introduction_Presentation
AditiBansal54083
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 

Uncovering breaking changes behind UI on mobile applications

  • 1. Uncovering breaking changes behind UI on mobile applications HeadSpin Senior Software Engineer, Device Automation
  • 2. Hi✋ • Kazuaki Matsuo • from ", GitHub: KazuCocoa, Twitter: @Kazu_cocoa • HeadSpin • Senior Software Engineer now, former was a test/QA engineer • Maintain Appium project
  • 3. Topics • Case study: • Combination of capturing HTTP requests over Appium scenarios • Tips: • Some tips for Appium
  • 5. App: Long running app • Many historical code • Multiple teams developed one app • Automated test environment was not matured enough • Both Android and iOS
  • 6. Situation: Collecting user flow • Tracking user behaviour is important • evaluate efforts by features, campaigns, etc • Should be reliable • The data was wrong case happened after releasing a new version • Unreliable data • Monitoring it, get rid of them from the analytics
  • 7. User events, flow Open the app Click the button Go to the view
  • 8. Events to track actions { “events”: [ { “name”: “OpenAnAppFromLauncher”, “time”: ”2019-06-09 13:39:04 +0900” # time series to track user actions }, { …. } ] }
  • 11. Store the log on the app Store the log { “events”: [ { “name”: “OpenAnAppFromLauncher”, “time”: ”2019-06-09 13:39:04 +0900” }
 ] }
  • 12. Send the log to the server Store the log Send to the stored log to server
  • 13. UI and non-UI • UI layer • User actions • non-UI layer • Store the data into local • Send it to servers UI no UI
  • 14. “behind UI” • Behind UI in this title means such non- UI layer • Event logs • HTTP requests • Too many event logs/few event logs unexpectedly
  • 16. Android • Android has two main component to build UIs • Activity • Base view • Fragment • Re-useable view component
  • 17. Lifecycle: Activity & Fragment Activity Fragment
  • 18. Before they are active Activity Fragment
  • 19. Where we set logs? Activity Fragment
  • 20. Easy to mistake • “Open”, from where? • Open the app from icon • Open the app from app history • Open the app from notification bar • Back button and go to the app view from another app • They would like to define user flow • We must define them correctly
  • 21. From App Icon? • “Open”, from where? • Open the app from icon • Open the app from app history • Open the app from notification bar • Back button and go to the app view from another app • They would like to define user flow • We must define them correctly
  • 22. From App History? • “Open”, from where? • Open the app from icon • Open the app from app history • Open the app from notification bar • Back button and go to the app view from another app • They would like to define user flow • We must define them correctly
  • 23. From App Notification Bar? • “Open”, from where? • Open the app from icon • Open the app from app history • Open the app from notification bar • Back button and go to the app view from another app • They would like to define user flow • We must define them correctly
  • 24. From Back Button? • “Open”, from where? • Open the app from icon • Open the app from app history • Open the app from notification bar • Back button and go to the app view from another app • They would like to define user flow • We must define them correctly
  • 25. Where we set logs, again Activity Fragment
  • 26. Fragment • Fragment is re-usable component • Unexpected usage: • A developer put a log into a fragment, for view A • Another developer uses the fragment in another view, for view B, while a log defined in the fragment should not be reused on view B • What happen if a user open the view A and B? • The log event happens on both view A and view B • The data will break since the log should be called only on view A View A View B
  • 27. iOS
  • 28. Change their implemented languages • Developers change their implementation languages • Objective-C -> Swift • Re-write to Swift, the behaviour should not change
  • 29. Both
  • 30. Prototype, Implement more • prototype/minimal implementation • Evaluate the value • It is worth • Re-write/refactor/add new features • Do not change logs to make the data comparable
  • 31. Various path to move views View A View B View D View C
  • 32. User flow View A View B View D View C
  • 33. Wrap up the issue behind UI • Logging user flows • Android has view lifecycle which is complicated • New programming language has been published • Developers rewrite/refactor their product code • Long running code has history • It is not easy to introduce new testable architecture
  • 35. Solution • Capture HTTP requests during test running by automation • Proxy server tools: WireMock, http_proxy • Can we prevent such breaks only human communication to make sure the behaviour? • Probably, sometimes we can, but we cannot almost time • Against release modules (or the same configuration)
  • 36. HTTP proxy server • Need a proxy server to capture the requests • We have some kind of ways to capture it
  • 37. How to capture the network? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 38. How to capture the network? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 39. How to capture the network? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 40. How to capture the network? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 41. How to capture the network? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 42. Where? WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on the device Reverse proxy Application Servers No proxy server Change app endpoint and connect directly
  • 43. Which way? • We can choose various points to capture the request • Which way was the most fit for us?
  • 44. Some points • Wanted to handle test environment in the test script • Would have like to start from small implementation • Less configuration in server side
  • 45. Direct connect WiFi Proxy serverNo proxy settings on the device Change Proxy Setting on Android device Reverse proxy No proxy server Application Servers Change app endpoint and connect directly
  • 46. How to connect to the proxy server? Proxy server Change app endpoint and connect directly Reverse proxy Application Servers • Change the endpoint with: 1.Build configuration (need rebuild) 2.Environment variables, process arguments, intent arguments 3.Change the preference via helper app like io.appium.settings
  • 47. 2nd way Proxy server Direct connect Reverse proxy Application Servers • Change the endpoint with: 1.Build configuration (need rebuild) 2.Environment variables, process arguments, intent arguments 3.Change the preference via helper app like io.appium.settings
  • 48. Test Communication flow between the Appium client to servers Proxy server Server Driver App Test target
  • 49. Which parts are handled by Ruby Proxy server Server Driver App Test target
  • 50. Capture the http requests in proxy server Proxy server Server Driver App Test target Capture data
  • 51. With Appium • Appium can control building test environment outside the app with the same script • Appium’s test cycle is before running the app under test • Leverage the system to iOS and Android • Espresso is after onCreate, XCTest is after launching the app • XCTest was not released when I started to try this issue (2016) • Espresso did not work on our app then (test not found happened frequently, then)
  • 52. Basic Appium flow Configure the device/the test app Run tests on the test device Remain apps/delete apps
  • 53. Appium’s test lifecycle Configure the device/the test app Run tests on the test device Remain apps/delete apps def setup() // call create session end def test_some_cases() // processes end def teardown() // quit end Can conducts tests Keeping the session
  • 54. Espresso/XCTest Configure the device/the test app Run tests on the test device Remain apps/delete apps Setup Test cases Teardown Runner install the test target before test scripts Espresso XCTest
  • 55. XCTest/Espresso • Below setup and test cases are called after finishing to install the test app class appiumConfTest: XCTestCase { override func setUp() { // simulator is already running XCUIApplication().launch() } func testExample() { } } @RunWith(AndroidJUnit4::class) class ExampleMainActivityTest { private val testWatcher = MyTestWatcher() private val scenarioRule = ActivityScenarioRule<MainActivity>( MainActivity::class.java) // AndroidTestRunner launch onCreate (for example) @get:Rule val ruleChain = RuleChain.outerRule(testWatcher) .around(scenarioRule) @Test fun test() { //... } } XCTest Espresso
  • 56. HTTP proxies • WireMock: https://github.com/tomakehurst/wiremock • Java • http_proxy: https://github.com/KazuCocoa/http_proxy • Elixir
  • 57. WireMock/http_proxy • Can control responses/requests as JSON format • Very handy to launch them as standalone { “request”: { “path”: “/request/path”, “port”: 8080, “method”: “GET” }, “response”: { “body”: “<html>hello world</html>“, “cookies”: {}, “headers”: { “Content-Type”: “text/html; charset=UTF-8", “Server”: “GFE/2.0" }, “status_code”: 200 } }
  • 58. Integrate with Appium • Launch proxy server before launching the test app • Can configure test environment from test scripts • Test lifecycle is greater than XCTest/Espresso • Before installing test apps ~ after uninstalling them
  • 59. Test suite Configure the device the test app Run tests on the test device Remain apps delete apps def setup() // call create session end def test_some_cases() // processes end def teardown() // quit end Start Stop Analyse the data Summarise test results Proxy
  • 60. Assert the captured data • Count the number of HTTP requests • Parse the JSON body and make sure the logs • If something happens, the Ruby script raises failure
  • 61. Summary • Test lifecycle on Appium • Getting HTTP requests via a proxy server • How I implemented the capturing data behind UI
  • 62. Tips
  • 63. 2nd way Proxy server Direct connect Reverse proxy Application Servers • Change the endpoint with: 1.Build configuration (need rebuild) 2.Environment variables, process arguments, intent arguments 3.Change the preference via helper app like io.appium.settings
  • 64. Process arguments • XCTest framework provides environment arguments for xcodebuild argument • An app can handle it as env[“PROCESS_VALUE"] in the app • The environment works only for the process { platformName: :ios, automationName: 'XCUITest', ... processArguments: { env: { "PROCESS_VALUE": "process value" } } }
  • 65. Packages, instrument args • Android case • We can make the release app debug mode with: • Launch an activity with the arguments (adb command) • Install a particular package name { platformName: :android, automationName: 'uiautomator2', ... optionalIntentArguments: '--ez key_name true’, } Package name: com.example.randome_package_names
  • 66. Simulating push notification, launch via history • When we would like to emulate background to foreground • Launch the all without auto launch • Launch the app with broadcast receiver • partially, we can emulate • suspend/back • Start activity with process arguments
  • 68. One more • HTTP request is not the only thing which happens behind the UI • CPU power etc • Recently, we can see “performance measurement feature” by Google and Apple to capture them in particular period • https://developers.google.com/web/fundamentals/performance/rail • This is mainly for Web, but this kind of performance should be same as mobile • XCTMetric, benchmark etc • https://github.com/KazuCocoa/droid-monitor • Easy to collect data by Android via add/linux commands • Nowadays, HeadSpin can do more rich thing tho… • HeadSpin (company, service)
  • 70. Takeaways • Happening behind UI is not easy to uncover, but they are also important • The benefit of Appium to configure test environment • Some tips to control the test app condition via Appium capability