DEV Community

Cover image for Why Your Maestro Flows Break Down as Your Test Suite Grows
Mayvin Ramasawmy
Mayvin Ramasawmy

Posted on

Why Your Maestro Flows Break Down as Your Test Suite Grows

A Maestro flow is a YAML file that taps and types through your app. When you write tapOn: "Login", Maestro looks for an element with that text. On a login screen, that text can match three elements: the tab, the toggle, and the submit button.

Maestro taps the first match and reports success. No warning, no error. The test is green, but it may have tapped the wrong thing.

The second problem shows up as you add more tests. Every test needs a logged-in user, so you copy the login steps into each flow. When the login screen changes, you update nine copies and miss the tenth.

Neither is a Maestro bug. Both come from how the flows are written. I covered the fixes in a two-part series:

๐ŸŽฏ How to pick a selector (text, id, index) and check what your test is really tapping
โ™ป๏ธ How to write the login steps once and reuse them in every test (runFlow)
๐Ÿ”€ How to handle a popup that only appears sometimes (when vs optional)
๐Ÿ” How to repeat steps safely (repeat) and avoid a loop that never ends
๐Ÿงน How to run setup before a test and cleanup after it (onFlowStart, onFlowComplete)
๐Ÿท๏ธ How to run only some tests, like a quick smoke check, using tags

One detail from Part 2: if a step in the middle of a flow fails any cleanup steps at the end never run. That leaves test data behind, like an account the test created and the next run starts with leftovers. onFlowComplete runs even when the main steps fail, so cleanup belongs there.

Part 1 covers selectors and reusing steps. Part 2 uses them to build the suite. You can read either one on its own, but they work best in order.

Part 1: https://www.mobile-automation.io/maestro-selectors-subflows/
Part 2: https://www.mobile-automation.io/maestro-flows-to-test-suite/

Top comments (0)