Skip to main content

sinew_testing 1.1.0 copy "sinew_testing: ^1.1.0" to clipboard
sinew_testing: ^1.1.0 copied to clipboard

Fakes and test helpers for apps built on Sinew. A dev dependency only.

sinew_testing #

pub package License Docs

Fakes and test helpers for apps built on Sinew. A dev dependency only.

A fake for every Sinew interface, so a test of your repository or notifier runs without a device, a network or a platform plugin, and fails the way the real thing fails.

Features #

  • mockHttp: a real Dio on a mock adapter, with routes and recorded requests
  • ControlledFetch: answer a pager's calls by hand, to test loading, retry and refresh in order
  • FakeKeyValueStore, FakeSecureStore, FakeFieldCipher, FakeBiometricVault, FakeTokenSource, FakeRefreshTokenStore, FakeNetworkChecker and FakeLocalizer
  • RecordingCrashReporter and installRecordingReporter, to assert what was reported
  • fixture to load a JSON fixture, and diskFullError and platformStorageError for storage failures

Getting started #

flutter pub add --dev sinew_testing

Usage #

Test a repository against a mock backend:

test('orders load', () async {
  final http = mockHttp((routes) => routes
      .on('GET', '/v1/orders').respond(200, body: fixture('orders_page.json')));
  final result = await OrderRepository(OrderApi(http.dio)).page(1);
  expect(http.requests.single.uri.path, '/v1/orders');
});

Hold a pager's calls open to test every state of a list:

final fetch = controlledFetch<Order>();
final pager = Pager<Order>.offset(fetch.call);

Sinew is one architecture for Flutter and Kotlin, released as a set of packages at one version.

Documentation #

License #

Apache 2.0, see LICENSE.