optitest 1.0.2
optitest: ^1.0.2 copied to clipboard
OptiTest — stable automation keys and testable widget wrappers for Flutter apps driven by Appium, Flutter Driver, or integration tests.
🧪 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.