activatory 0.0.8

  • Example
  • Installing
  • Versions
  • 49

Activatory #

Build Status Pub

This project is aimed to bring a test data generator to Dart's ecosystem. This will greatly simplify unit testing and especially Test-Driven Development.

This project is inspired by .NET Autofixture library.

Supported features #

  • Effortless primitive types (String, int, double, bool, DateTime, enums) generating
  • Effortless complex object generating using constructors/factory methods/named constructors (default values for arguments are preferred)
  • Overriding default generating behavior with custom factories, pinned values defined by user or auto generated
  • Overriding default generating behavior for specific cases using any object as a key

Roadmap #

This is my first Dart project and, actually, this is "pet-project". So there are no exact plans and etc. For planned features and more see enhancements on github.

v0.0.1-0.0.4 #

  • Added support for primitive objects activation: int, double, String, bool, DateTime
  • Added support for complex object activation by calling ctors, named ctors, factories and using positional arguments

v0.0.5 #

  • Named arguments supported
  • Complex object activation now respects default non null values

v0.0.6 #

  • Added ability to register factory explicitly

v0.0.7 #

  • Added ability to register generated singleton
  • Added ability to register pre defined value

v0.0.8 #

  • Back-ends now can be registered and lookuped using any object as a key
  • useSingleton renamed to pin, useValue renamed to pinValue


import 'package:activatory/src/activatory.dart';

main() {
  var activatory = new Activatory();

  // We can create primitive types
  print('Int: ${activatory.getTyped<int>()}');
  print('String: ${activatory.getTyped<String>()}');
  print('DateTime: ${activatory.getTyped<DateTime>()}');
  print('Bool: ${activatory.getTyped<bool>()}');
  print('TestEnum: ${activatory.getTyped<TestEnum>()}');

  //We can create complex types
  var complexClassInstance = activatory.getTyped<SomeComplexClass>();
  print('Complex.String: ${complexClassInstance.stringField}');

  //And yes, we can create them recursively
  var moreComplexClassInstance = activatory.getTyped<MoreComplexClass>();
  print('MoreComplex.DateTime: ${moreComplexClassInstance.dateTimeField}');
  print('MoreComplex.Complex.String: ${moreComplexClassInstance.someComplexClass.stringField}');

  //See activatory_test.dart for full feature list

class MoreComplexClass {
  DateTime _dateTimeField;
  SomeComplexClass _someComplexField;

  MoreComplexClass(this._dateTimeField, this._someComplexField);
  DateTime get dateTimeField => _dateTimeField;

  SomeComplexClass get someComplexClass => _someComplexField;

class SomeComplexClass {
  String _stringField;

  String get stringField => _stringField;

enum TestEnum { A, B, C }

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  activatory: ^0.0.8

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:activatory/activatory.dart';
Version Uploaded Documentation Archive
0.0.19 Feb 17, 2019 Go to the documentation of activatory 0.0.19 Download activatory 0.0.19 archive
0.0.18 Feb 16, 2019 Go to the documentation of activatory 0.0.18 Download activatory 0.0.18 archive
0.0.17 Feb 10, 2019 Go to the documentation of activatory 0.0.17 Download activatory 0.0.17 archive
0.0.16 Jan 19, 2019 Go to the documentation of activatory 0.0.16 Download activatory 0.0.16 archive
0.0.15 Jan 19, 2019 Go to the documentation of activatory 0.0.15 Download activatory 0.0.15 archive
0.0.14 Jan 17, 2019 Go to the documentation of activatory 0.0.14 Download activatory 0.0.14 archive
0.0.13 Jan 13, 2019 Go to the documentation of activatory 0.0.13 Download activatory 0.0.13 archive
0.0.12 Jan 12, 2019 Go to the documentation of activatory 0.0.12 Download activatory 0.0.12 archive
0.0.11 Jan 7, 2019 Go to the documentation of activatory 0.0.11 Download activatory 0.0.11 archive
0.0.10 Jan 6, 2019 Go to the documentation of activatory 0.0.10 Download activatory 0.0.10 archive

All 19 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1


Detected platforms: web, other

Primary library: package:activatory/activatory.dart with components: mirrors.

Health suggestions

Format lib/activatory.dart.

Run dartfmt to format lib/activatory.dart.

Format lib/src/activation_context.dart.

Run dartfmt to format lib/src/activation_context.dart.

Format lib/src/activation_context_factory.dart.

Run dartfmt to format lib/src/activation_context_factory.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/activatory.dart (Run dartfmt to format lib/src/activatory.dart.)
  • lib/src/backends/complex_object_backend.dart (Run dartfmt to format lib/src/backends/complex_object_backend.dart.)
  • lib/src/backends/primitive_random_backends.dart (Run dartfmt to format lib/src/backends/primitive_random_backends.dart.)

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
uuid ^2.0.0-rc1 2.0.0
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
typed_data 1.1.6
Dev dependencies
test ^1.0.0