Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Maestro: A paradigm shift in UI testing

Maestro: A paradigm shift in UI testing

Amanjeet Singh

November 30, 2022
Tweet

More Decks by Amanjeet Singh

Other Decks in Programming

Transcript

  1. Definition Story📕 • Develop more features • More features =

    More Money • More subdivisions created, coming soon with more features
  2. Definition Story📕 • Develop more features • More features =

    More Money • More subdivisions created, coming soon with more features
  3. Definition Story📕 • Workload increases • Develop more features •

    More features = More Money • More subdivisions created, coming soon with more features
  4. Definition Story📕 • Workload increases • Feature complexity increases ⏫

    • Develop more features • More features = More Money • More subdivisions created, coming soon with more features
  5. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • Develop more features • More features = More Money • More subdivisions created, coming soon with more features
  6. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features
  7. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button
  8. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen
  9. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing
  10. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization:
  11. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization: We need to test before we ship
  12. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization: We need to test before we ship
  13. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization: We need to test before we ship • Hire QA engineers
  14. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization: We need to test before we ship • Hire QA engineers • Start writing unit tests for the features
  15. Definition Story📕 • Workload increases • Feature complexity increases •

    Reports from users: ⏫ • I am not able to login • Develop more features • More features = More Money • More subdivisions created, coming soon with more features • I am not able to click on the Add to Cart button • My app crashes when I go on Payments screen • Still Increasing • Realization: We need to test before we ship • Hire QA engineers • Start writing unit tests for the features
  16. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised
  17. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Onboarding cost to automation tools
  18. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Onboarding cost to automation tools • Setting up automation tools is painful
  19. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  20. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful • Time to get first flow automation working
  21. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  22. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  23. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Different API level devices • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  24. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Different API level devices • Managing traffic of builds • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  25. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Different API level devices • Managing traffic of builds • Different OEMs devices • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  26. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Different API level devices • Managing traffic of builds • Different OEMs devices • More • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  27. Definition Story📕 Automation More Features • Started testing manually before

    releasing • Reports reduced and app got stabilised • Time to get first flow automation working • Infrastructure to run tests • Different API level devices • Managing traffic of builds • Different OEMs devices • More • CI integration • Onboarding cost to automation tools • Automation tools are “non-declarative” • Setting up automation tools is painful
  28. Definition Story📕 User Reports Functional Bugs • App is launching

    slowly • Patterns in user reports • Gap between QAs and Developers
  29. Definition Story📕 User Reports Functional Bugs • App is launching

    slowly • Battery draining • Patterns in user reports • Gap between QAs and Developers
  30. Definition Story📕 User Reports Functional Bugs • App is launching

    slowly • Battery draining • Activity starts slowly • Patterns in user reports • Gap between QAs and Developers
  31. Definition Story📕 User Reports Functional Bugs • App is launching

    slowly • Battery draining • Activity starts slowly Non Functional Bugs • Patterns in user reports • Gap between QAs and Developers
  32. Definition Story📕 User Reports Functional Bugs • App is launching

    slowly • Battery draining • Activity starts slowly Non Functional Bugs • Appium support for solving Non Functional Bugs ☹ • Patterns in user reports • Gap between QAs and Developers
  33. • Setup should be very easy • Starting and writing

    first flow should be easy Ideal setup for UI testing at scale
  34. • Setup should be very easy • Starting and writing

    first flow should be easy • Integration with CI should be very easy Ideal setup for UI testing at scale
  35. • Setup should be very easy • Starting and writing

    first flow should be easy • Integration with CI should be very easy • Managing infrastructure should be easy Ideal setup for UI testing at scale
  36. • Helpful for dealing with functional and non-functional issues •

    Setup should be very easy • Starting and writing first flow should be easy • Integration with CI should be very easy • Managing infrastructure should be easy Ideal setup for UI testing at scale
  37. or curl -Ls "https://get.maestro.mobile.dev" | bash Setup should be Easy

    brew tap mobile-dev-inc/tap brew install maestro
  38. or curl -Ls "https://get.maestro.mobile.dev" | bash Setup should be Easy

    brew tap mobile-dev-inc/tap brew install maestro
  39. Starting and writing first flow • Declarative, in YAML format

    ✅ • Hot reload or continues mode ✅
  40. Starting and writing first flow • Declarative, in YAML format

    ✅ • Hot reload or continues mode ✅ • Lets open twitter app and follow account
  41. Starting and writing first flow appId: com.twitter.android --- - launchApp

    maestro test -c ./follow.yaml - tapOn: Search and Explore
  42. Starting and writing first flow appId: com.twitter.android --- - launchApp

    maestro test -c ./follow.yaml - tapOn: Search and Explore - tapOn: Search Twitter - inputText: "@mobile__dev" - tapOn: mobile.dev - tapOn: Follow - assertVisible: Following
  43. More commands • Index • Width, height • Relative positioning

    • Tap on commands • id of view • More
  44. More commands • Tap on commands • Long press -

    longPress: “text” 
 or - longPress: 
 id: “@id_some_view_id” 

  45. More commands • Tap on commands • Long press •

    Swiping - swipe: 
 direction: RIGHT 
 duration: 300 
 - swipe: 
 start: x1, y1 
 end: x2, y2 
 duration: 400 

  46. More commands • Tap on commands • Long press •

    Swiping • Erase Text - eraseText
  47. More commands • Tap on commands • Long press •

    Swiping • Erase Text • Much more: https://maestro.mobile.dev/reference
  48. Sit back! • No need of idling resource • No

    need pepper test case with Thread.sleep
  49. Sit back! • No need of idling resource • No

    need pepper test case with Thread.sleep appId: com.squareup name: Sign Up --- - launchApp - tapOn: Create account - tapOn: text: Accept all cookies optional: true - inputText: ${EMAIL} - tapOn: Continue - inputText: ${PASSWORD} - tapOn: Continue - tapOn: rightOf: I agree to.* retryTapIfNoChange: false - tapOn: Continue - tapOn: Confirm
  50. Sit back! • No need of idling resource • No

    need pepper test case with Thread.sleep • Not much jargon involved, making maestro tests sharable source
  51. Sit back! • No need of idling resource • No

    need pepper test case with Thread.sleep • Decouples with codebase, blazing fast iterations • Not much jargon involved, making maestro tests sharable source
  52. Sit back! • No need of idling resource • No

    need pepper test case with Thread.sleep • Decouples with codebase, blazing fast iterations • Not much jargon involved, making maestro tests sharable source • And, cross platform !
  53. Dealing with Functional Bugs • Maestro test command outputs •

    Locally • JUnit type format output available <?xml version='1.0' encoding='UTF-8'?> <testsuites> <testsuite name="Test Suite" device="emulator-5554" tests="1" failures="1"> <testcase id="follow" name="follow"> <failure>Element not found: Text matching regex: Follow</failure> </testcase> </testsuite> </testsuites>
  54. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic
  55. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic • Following twitter page flow
  56. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic • Following twitter page flow • Write Maestro Flow
  57. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic • Following twitter page flow • Write Maestro Flow • Run: adb shell dumpsys gfxinfo com.twitter.android framestats
  58. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic • Following twitter page flow • Write Maestro Flow • Run: adb shell dumpsys gfxinfo com.twitter.android framestats • Collect output and capture important metrics
  59. Dealing with Non-Functional Bugs • Frame drops 😖 • Identify

    core flows of app which have high user traffic • Following twitter page flow • Write Maestro Flow • Run: adb shell dumpsys gfxinfo com.twitter.android framestats • Collect output and capture important metrics • Repeat
  60. Dealing with Non-Functional Bugs • Root Causing Window: com.twitter.android/com.twitter.app.main.MainActivity Stats

    since: 100942401883393ns Total frames rendered: 387 Janky frames: 110 (28.42%) 50th percentile: 9ms 90th percentile: 22ms 95th percentile: 34ms 99th percentile: 450ms
  61. Dealing with Non-Functional Bugs • Root Causing Window: com.twitter.android/com.twitter.app.main.MainActivity Stats

    since: 100942401883393ns Total frames rendered: 387 Janky frames: 110 (28.42%) 50th percentile: 9ms 90th percentile: 22ms 95th percentile: 34ms 99th percentile: 450ms
  62. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations
  63. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations Debug API
  64. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations Debug API Debug.startMethodTracingSampling( context.cacheDir, maxBufferSize, samplingIntervalUs )
  65. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations Debug API Debug.startMethodTracingSampling( context.cacheDir, maxBufferSize, samplingIntervalUs ) Debug.stopMethodTracing() …… …… ……
  66. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations
  67. Dealing with Non-Functional Bugs • Root Causing • Monitor janky

    frame percentage • Generate flame graphs to narrow down on heavy operations • Capture Strict mode violations
  68. Integrate with CI maestro cloud <app-file> ./maestro —apiKey <api-key> Test

    directory <root> | 
 |___.maestro/ 
 | | 
 | |____ Login.yaml | | 
 | |____ Add to Cart.yaml |
  69. Integrate with CI • Device management and scaling maestro cloud

    <app-file> ./maestro —apiKey <api-key> • Integrate with PRs ✅ ✅
  70. Integrate with CI maestro cloud <app-file> ./maestro —apiKey <api-key> •

    Natively integrating with your CI: Github, Gitlab, Bitbucket, etc. • Integrate with PRs ✅ ✅ • Device management and scaling ✅
  71. Integrate with CI maestro cloud <app-file> ./maestro —apiKey <api-key> •

    Natively integrating with your CI: Github, Gitlab, Bitbucket, etc. • Integrate with PRs ✅ ✅ • Device management and scaling ✅ • Trigger on PR stage ✅
  72. Integrate with CI maestro cloud <app-file> ./maestro —apiKey <api-key> •

    Natively integrating with your CI: Github, Gitlab, Bitbucket, etc. • Integrate with PRs ✅ ✅ • Device management and scaling ✅ • Trigger on PR stage ✅ • Different API level devices ✅
  73. Ideal setup of UI testing • Helpful for dealing with

    functional and non-functional issues • Setup should be very easy • Starting and writing first flow should be easy • Integration with CI should be very easy • Managing infrastructure should be easy ✅ ✅ ✅ ✅ ✅
  74. Community Support is Great • Performance tool to get FPS,

    CPU usage for search and explore interaction by Bamlab: https://twitter.com/almouro/status/1595402239044198400
  75. Community Support is Great • Performance tool to get FPS,

    CPU usage for search and explore interaction by Craig Atkinson: https://www.atkinsondev.com/post/android-maestro-mock-rest-api/ • Mock API servers for Maestro Android testing using MockServer and Gradle
  76. Community Support is Great • Performance tool to get FPS,

    CPU usage for search and explore interaction by Craig Atkinson: https://www.atkinsondev.com/post/android-maestro-testing/ • Mock API servers for Maestro Android testing using MockServer and Gradle • High level UI testing with Maestro
  77. Community Support is Great by Manish Verma: https://twitter.com/mobile__dev/status/1580952966474846209 • Facebook

    registration flow automation • Performance tool to get FPS, CPU usage for search and explore interaction • Mock API servers for Maestro Android testing using MockServer and Gradle • High level UI testing with Maestro
  78. Community Support is Great by Manish Verma: https://twitter.com/mobile__dev/status/1580952966474846209 • Facebook

    registration flow automation • Performance tool to get FPS, CPU usage for search and explore interaction • Mock API servers for Maestro Android testing using MockServer and Gradle • High level UI testing with Maestro • Much more: Join Maestro slack community !!