Skip to content

hasankarli/example_tests

Repository files navigation

example_tests

A Flutter e‑commerce demo with a full test pyramid: unit, widget, integration, and E2E (Appium/WebdriverIO). Covers permission-heavy onboarding, catalog/search/cart, and CI options (Slack, Firebase Test Lab, BrowserStack).

Highlights

  • Onboarding with location, camera, notification, and optional ATT steps; test toggles (skipPermissionRequests, includeATTStepForTesting) keep integration runs deterministic without real permission dialogs.
  • Provider-based state with services/models for categories, products, and cart; unit tests use mocks.
  • Semantics on search, product cards, and cart so widget and E2E can share the same element lookup.
  • Layered automation: Dart unit/widget in test/, device flows in integration_test/, Appium (WebdriverIO) in e2e/.

Test pyramid (guideline)

Layer Focus
Unit Providers, services, models
Widget Screens, components, semantics
Integration Full app flows on device
E2E Real APK/IPA via Appium

Coverage is measured with flutter test --coverage (unit + widget only). Aim for high coverage on critical lib/ code; integration and E2E stay small and focused on critical flows.

Getting started

  1. Flutter 3.9+, Android Studio / Xcode.
  2. flutter pub get then flutter run.

For E2E: Node.js 16+, Appium Server, Android/iOS drivers — see e2e/README.md.

Running tests

Unit & widget

flutter test test/unit
flutter test test/widget

Integration (Flutter)
Uses test flags so permission dialogs are skipped; flows stay deterministic.

flutter test integration_test

E2E (Appium + WebdriverIO)

cd e2e && npm install
npm test
npm run test:android
npm run test:shopping

Use APP_PATH, PLATFORM and other env vars; see e2e/driver.config.js.

Scripts & CI

  • ./run_tests.sh — pub get, format, analyze, unit + widget tests, LCOV/HTML.
  • ./run_coverage.sh / coverage.sh — coverage output (unit + widget).

GitHub Actions workflows:

Workflow Trigger Purpose
test.yml workflow_dispatch E2E on Android emulator; screenshots, recordings, artifacts; optional Slack. Secrets: SLACK_WEBHOOK_URL (failure notification), SLACK_BOT_TOKEN, SLACK_CHANNEL_ID (per-test results + uploads).
test-firebase.yml workflow_dispatch APK to Firebase Test Lab; Robo test on real device. Secrets: GCP_SA_KEY, GCP_PROJECT_ID.
test-browserstack.yml workflow_dispatch Same E2E suite on BrowserStack App Automate. Secrets: BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY. Optional input: apk_url to skip build.

Structure

Path Contents
lib/ App: splash, onboarding, catalog, product detail, cart, checkout, search, widgets
test/unit Provider/service tests (Mockito)
test/widget Screen and widget tests, semantics
integration_test/ Onboarding, cart, search, app launch flows
e2e/ WebdriverIO config, helpers, suites (onboarding, cart, shopping)
analysis_options.yaml flutter_lints and project rules

Related

Related: Flutter Test Pyramid: Layers, Coverage, and E2E with Appium

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published