easy_test_app 0.1.3
easy_test_app: ^0.1.3 copied to clipboard
App-agnostic core for widget-testing Flutter apps. Ships the easyTestWidgets harness, an app launcher + journey model, value/matcher request helpers, header and error builders, the platform mock, and [...]
easy_test_app #
App-agnostic building blocks for full-app widget tests of Flutter apps. It holds the parts that don't change between apps — the test harness, the launch + journey model, request matchers, and the platform mock — so each app only supplies its own glue.
What's in the box #
easyTestWidgets(...)— atestWidgetswrapper that swallows prints, installs the transport mocks (easy_mock_http), the unmocked-channel guard, and the defaultSystemChannelsmocks, then runs your callback. App-specific setup is injected:init— install the app's own fakes (secure storage, permissions, device info, Firebase boot, …) before the app is launched.appJourney— the journey whosestepsare reset after each test.tearDown— extra cleanup.
appLauncher({app, patrol, appJourney})— pumps the widget and runs eachJourneyStep'sprepare(stub HTTP) thenwalk(drive the UI).AppJourney/JourneyStep— the journey abstraction. SubclassAppJourneyper app to add fluent steps (signIn(),acceptPolicy(), …).value/matcher/Any/ValueOrMatcher— pass a concrete value or aMatcherwherever an HTTP-case field is expected;mapValuetransforms a concrete value while letting a matcher pass through.httpHeaders()/authHttpHeaders()/HeaderBuilder— build expected request headers, with or without a bearer token.LazyVerification— aeasy_mock_httpVerificationresolved lazily.mockPlatform— flipdefaultTargetPlatformto Android / iOS.PatrolTester.pumpUntil/releasePendingAsync,PatrolFinder.ensureNotExist.
Firebase fakes moved to the separate easy_mock_firebase package.
Composing it in an app #
// test/core/core.dart (in your app)
@isTest
void appWidgetTest(String description, PatrolWidgetTestCallback callback) {
easyTestWidgets(
description,
callback,
init: () async {
mockSecureStorage.init();
// … the rest of this app's fakes …
},
appJourney: () => _appJourney, // your AppJourney subclass
);
}
Everything is exported from the single barrel:
import 'package:easy_test_app/easy_test_app.dart';