TestDirector<Unit, Args> class

A class that combines ArgsBuilder and UnitBuilder to provide a flexible and reusable way to set up and construct test scenarios.

TestDirector is designed to be extended or used directly in test files to create organized and maintainable test setups, especially for Flutter widget tests.

The Unit type parameter typically represents the widget or object being tested, while Args represents the arguments used to construct the unit.

Usage:

class MyUnitTestDirector extends TestDirector<MyClass, String> {
  MyUnitTestDirector() {
    setUnitFactory((args) => MyClass(value: args));
  }
}

void main() {
  late MyUnitTestDirector director;

  setUp(() {
    director = MyUnitTestDirector();
  });

  test('MyClass behaves correctly', () {
    director.setArgs('test value');
    final myObject = director.construct();
    expect(myObject.value, equals('test value'));
  });
}
Mixed-in types
Implementers

Constructors

TestDirector()

Properties

args ↔ Args
The built arguments, available after buildArgs is called.
latefinalinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unit ↔ Unit
The built unit, available after buildUnit is called.
latefinalinherited

Methods

addUnitArrangement(Unit arrangement(Unit)) → void
Adds an arrangement function to modify or wrap the unit after its initial creation.
inherited
buildArgs() → Args
Builds the arguments using either the set args or the args factory.
inherited
buildUnit(Args args) → Unit
Builds the unit using the factory and applies all arrangements.
inherited
construct() → Unit
Constructs the Unit using the provided Args.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setArgs(Args args) → void
Sets the arguments directly.
inherited
setArgsFactory(covariant ArgsFactory<Args> argsFactory) → void
Sets the factory function used to create arguments.
inherited
setUnitFactory(UnitFactory<Unit, Args> unitFactory) → void
Sets the factory function used to create the initial unit.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited