android reactnative uitesting

32
Vishal Android Test Night #2 Android React Native UITesting

Upload: vishal-banthia

Post on 23-Jan-2018

183 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Android ReactNative UITesting

VishalAndroid Test Night #2

Android React Native UITesting

Page 2: Android ReactNative UITesting

Software Engineer in Test

Case Study (Mobile Automation)

SWET (past)

Core Member

Vishal Banthia @vbanthia @vbanthia_

Page 3: Android ReactNative UITesting

Some Previous Talks, Blogs & Tutorials

• Android E2E Testing at Mercari @ Android Test Night

• Reliable Mobile Test Automation @SRE-SET Automation Night

• Android Device Farm at Mercari

• Appium Docker Demo

• STF Appium Example

Page 4: Android ReactNative UITesting

• About React Native

• Automating React Native UITests using Appium

• Current problems with React Native tests

• Next plan

Agenda

Page 5: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定In June, we had a major update in mercari US app.

mercari US app

Native Native Native React-Native

Page 6: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定• Because its NATIVE not hybrid• Cross Platform. Works for both android and iOS• Reusable UI components• Faster development with Live-Reload feature• Can deploy anytime like backend. No Apple pain!• Many more ...

Why React-Native

Page 7: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

UITesting ...

Page 8: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Automation Architecture

RubyAppium

(UIAutomator2)

Test Script Automation tool App Under Test

Page 9: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Automation Architecture

RubyAppium

(UIAutomator2)

Test Script Automation tool App Under Test

Page 10: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Problem ...

Page 11: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

React Native View Hierarchy

Page 12: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Appium supports following finders

id => view resource-id

accessibility_id => view content-description

Page 13: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

React Native View Hierarchy

Page 14: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

React Native Documentation for TestID

https://facebook.github.io/react-native/docs/view.html#testid

Page 15: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Let’s add testId

Page 16: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Nothing changed …

Page 17: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

In case of android react-native testId property does not add either resource-id or content-desc. They add this value into a different view property called `tags`.

Unfortunately, there is no way to find an element using tags through UIAutomator driver.

Also, currently there is no way to add `resource-id` in react-native. All efforts (PR) have been rejected because they conflict with facebook internal test framework.

Long Battle: https://github.com/facebook/react-native/pull/9942

Page 18: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Solution ...

Page 19: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Add accessibilityLabel

● testID for iOS

● accessibilityLabel for Android which set content-desc

Page 20: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Add accessibilityLabel ...

Page 21: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

After this test automation was possible using Appium similar to Native App

Page 22: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Current Problems

• Adding testID does not work as expected sometime because we need to make all above parents also accessible

• Adding testID and accessibilityLabel does not have same effect on iOS and android respectively. So, need to confirm on both platform after addition

• With accessibilityLabel approach, application will not be friendly for Visually Impaired people

Page 23: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定• ReactNative tests are more flaky compare to Native Test

Current Problems

Page 24: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定• UI Rendering approach and lifecycle is different in ReactNative compare to Native app

• Approaches or Practices being used for Native app tests sometime fails because of this reason

Why tests are more flaky?

Page 25: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Future Plan ...

https://hackernoon.com/detox-gray-box-end-to-end-testing-framework-for-mobile-apps-196ccd9564ce

Page 26: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Detox

Gray box, not black box

Page 27: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定Tests run in same process

Can access memory

Cannot ship binary which is used for

testing

Black Box Gray Box

Test Script does not know about what

is happening inside Test Target App

Can use only API provided by OS

It is more like testing similar to what

an end user can do

Can ship same binary which went

under testing

Page 28: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Gray Box Testing ...

Page 29: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Detox …

Detox uses Espresso for Android and EarlGray for iOS

Page 30: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

How Detox Works ...

Page 31: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Conclusion

Till now, I was also in favour of Black box testing but

now I also think Gray Box approach is better and

more reliable

Page 32: Android ReactNative UITesting

マスタータイトルの書式設定

• マスターテキストの書式設定

Thank You!