activatory 0.0.10

  • Example
  • Installing
  • Versions
  • 48

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
  • Arrays generating: it is effortless for primitive types and require explicit registration for enums and complex types

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

v0.0.9 #

  • Added effortless support for primitive types arrays generating (except of enums arrays)
  • Added support for complex types array generating with explicit array registration
  • Fixed enum generation bug (generated values was not real enum values from values list)

v0.0.10 #

  • Added custom exception type for all library internal errors


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.10

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.20 Mar 3, 2019 Go to the documentation of activatory 0.0.20 Download activatory 0.0.20 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

All 20 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 May 30, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17


Detected platforms: web, other

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

Health suggestions

Fix lib/activatory.dart. (-0.50 points)

Analysis of lib/activatory.dart reported 1 hint:

line 5 col 9: Name libraries using lowercase_with_underscores.

Fix lib/src/backends/complex_object_backend.dart. (-0.50 points)

Analysis of lib/src/backends/complex_object_backend.dart reported 1 hint:

line 87 col 12: Use isEmpty instead of length

Fix lib/src/backends/explicit_backend.dart. (-0.50 points)

Analysis of lib/src/backends/explicit_backend.dart reported 1 hint:

line 1 col 8: Unused import: 'package:activatory/activatory.dart'.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/activation_context.dart (Run dartfmt to format lib/src/activation_context.dart.)
  • lib/src/backends/primitive_random_backends.dart (Run dartfmt to format lib/src/backends/primitive_random_backends.dart.)
  • lib/src/generator.dart (Run dartfmt to format lib/src/generator.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.1
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