mockable 0.2.2 copy "mockable: ^0.2.2" to clipboard
mockable: ^0.2.2 copied to clipboard

Annotation and runtime helpers for generating realistic mock instances of your Dart classes. Pairs with mockable_gen for build_runner code generation.

example/mockable_example.dart

// Demonstrates the MockFaker runtime helpers. The annotation + generated
// extensions are demonstrated in the mockable_gen package's example.

import 'package:mockable/mockable.dart';

void main() {
  // Deterministic for reproducibility — drop this for varied output.
  MockFaker.seed(2026);

  print('email:      ${MockFaker.email()}');
  print('name:       ${MockFaker.name()}');
  print('phone (us): ${MockFaker.phone()}');
  print('phone (sa): ${MockFaker.phone(locale: 'sa')}');
  print('id:         ${MockFaker.id()}');
  print('uuid:       ${MockFaker.uuid()}');
  print('shortCode:  ${MockFaker.shortCode()}');
  print('sentence:   ${MockFaker.sentence()}');
  print('integer:    ${MockFaker.integer(min: 18, max: 80)}');
  print('currency:   ${MockFaker.currency()}');
  print('dateString: ${MockFaker.dateString()}');
}
2
likes
160
points
204
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Annotation and runtime helpers for generating realistic mock instances of your Dart classes. Pairs with mockable_gen for build_runner code generation.

Repository (GitHub)
View/report issues

Topics

#code-generation #mock #testing #skeletonizer

License

MIT (license)

Dependencies

faker, meta

More

Packages that depend on mockable