π§ͺ OptiTest
Stable automation identity for every Flutter widget.
One wrapper Β· deterministic keys Β· native semantics β Appium-ready out of the box.
π₯ Why OptiTest?
Appium suites shatter the moment keys are ad-hoc or layouts shift. OptiTest gives every widget one deterministic, namespaced tag β readable by Flutter tests and native drivers on iOS, Android, and web.
Testable(
testId: TestKey.button('login_submit'),
child: SubmitButton(),
)
// Appium locator β btn_login_submit
| β‘ | Feature |
|---|---|
| β | 30 element types β button, input, listItem, bottomSheet, qrCode, β¦ |
| β | State suffixes β disabled, loading, error, selected |
| β | Native semantics β same tag on Android, iOS, web β no extra wiring |
| β | Zero dependencies β pure Flutter, no codegen, no reflection |
| β | 40-char safe β auto-truncated to stay inside Appium limits |
π Install
flutter pub add optitest
β‘ One-Minute Example
import 'package:optitest/optitest.dart';
Column(
children: [
Testable(
testId: TestKey.input('login_email'),
child: TextField(decoration: InputDecoration(labelText: 'Email')),
),
Testable(
testId: TestKey.button('login_submit', state: ElementState.loading),
child: FilledButton(onPressed: null, child: Text('Loadingβ¦')),
),
],
)
// β inp_login_email
// β btn_login_submit_loading
Full working sample in example/.
π Documentation
| Guide | What's inside |
|---|---|
| π Usage Guide | Every pattern β inputs, lists, state variants, anti-patterns |
| π Key Reference | All 30 element types, prefixes, state suffixes |
| π€ Appium Integration | Locators for iOS, Android, WebdriverIO, Flutter Driver |
| β Testing Best Practices | Tag by intent, namespace per screen, index lists |
π§© Part of the opti* Toolkit
| Package | Purpose |
|---|---|
| π OptiCore | BLoC micro-framework |
| β‘ OptiKit CLI | Scaffolding & builds |
| π§ͺ OptiTest | Automation identity (this package) |
π Issues & Contributions
Found a bug or want a new element type? Open an issue on GitHub β PRs welcome.
π€ Author
Built with β€οΈ by Mahmoud El Shenawy
π License
MIT β free for personal and commercial use.
Libraries
- optitest
- OptiTest β stable automation keys and testable widget wrappers for Flutter apps targeted by Appium, Flutter Driver, or integration tests.