mogen_unit_tests library
CLI tool that scans a Flutter project's feature folders, parses its
state-management classes — Riverpod Notifier/AsyncNotifier as well as
flutter_bloc Bloc/Cubit — detects their dependencies, and generates
Mocktail-based unit tests with success and error cases for every action.
Riverpod notifiers get ProviderContainer tests; blocs and cubits get
bloc_test (blocTest<B, S>(...)) tests.
Run from your Flutter project root:
dart run mogen_unit_tests
Classes
- BlocTestGenerator
-
Generates a complete
bloc_test+ Mocktail test file for oneflutter_blocNotifierInfo — aBloc<Event, State>or aCubit<State>. - DependencySelector
- Decides which of a class's discovered dependencies are worth mocking.
- EventClassInfo
-
A bloc event class discovered in the source tree, with the constructor
shape needed to instantiate it inside a generated
act:callback. - EventInfo
-
One event a
Blochandles, discovered from anon<Event>(...)registration in the bloc's constructor. - EventParser
-
Parses bloc event classes so the generator can construct a real event
instance inside
act:(bloc.add(LoginRequested(email: '', ...))). - FeatureBundle
- A discovered feature with its logic, state and event source files.
- FeatureScanner
-
Scans
lib/featuresand groups logic (notifier / bloc / cubit), state and event files by feature. - ImportResolver
-
Resolves the
importlines a generated test needs for the types it mentions: dependencies, entities, models and states. - MethodInfo
- A public method on the notifier that will receive generated test cases.
- MockValueGenerator
- Maps a Dart type string to a sensible literal for generated test scaffolding.
- NotifierInfo
-
Everything the generator needs to know about one state-management class:
a Riverpod notifier, a
flutter_blocBloc, or aCubit. - NotifierParser
- Parses a notifier, bloc or cubit source file and returns all NotifierInfo found.
- OrchestratorResult
- Summary of the results produced by a test generation run.
- ParamInfo
- A single method or constructor parameter.
- RepositoryDep
- A repository or service dependency detected inside the notifier.
- StateField
- A single field declared on a state class.
- StateInfo
-
Information about the matching state class found in the
states/folder. - StateParser
-
Parses state files in
presentation/states/and extracts field types so the generator can produce type-accurate mock data. - StubWriter
-
Writes the
when(...)stubs, fallback registrations and input declarations that both generators emit identically. - TestGenerator
- Generates a complete Mocktail + Riverpod test file for one NotifierInfo.
- TestOrchestrator
-
Runs the feature scan and writes generated tests into
test/unit/features.
Enums
- StateManagementKind
- The state-management framework a scanned logic class belongs to.