We cannot detect crashes that occur while navigating through the screens, opening the app, incompatible image assets etc with the help of Unit or Integration tests. Opening and navigating through the app manually is the only way to identify them. Crashes like these can be detected via UI tests where we write tests for a set of screen interactions. We use Maestro for UI testing in Simple as it offers a single binary tool that works anywhere with declarative yet robust syntax and has a quick learning curve.
Setup Maestro CLI on the system with the Homebrew
brew tap mobile-dev-inc/tap
brew install maestro
A Flow is a series of steps that tell Maestro how to navigate the application. Here are some commonly used steps in a flow.
clearState
- clears the application statelaunchApp
- launches the apptapOn
- taps on a view on the screenassertVisible
- asserts whether an element is visibleinputText
- inputs text
More Maestro flow commands can be found here.
Below is an example of how to test login flow in Simple. Flow can be found here
appId: org.simple.clinic.staging
---
- clearState
- launchApp
- tapOn: "Next"
- tapOn: "Get started"
- tapOn:
below:
id: "select_country_title"
- tapOn:
below:
id: "select_state_title"
- inputText: ${number}
- tapOn: "Next"
- assertVisible:
text: "Your security PIN"
- inputText: ${pin}
- tapOn: "Enter code"
- inputText: ${otp}
- tapOn: "Got it"
Flow can be run using the maestro test
command.
maestro test login_flow.yaml
Params to the flow can be given from the terminal as given below
maestro test -e number=0123456789 -e pin=0000 -e otp=000000 uiFlows/login_flow.yaml