mogen_integration_tests 1.0.4 copy "mogen_integration_tests: ^1.0.4" to clipboard
mogen_integration_tests: ^1.0.4 copied to clipboard

Scans datasource GET endpoints and auto-generates integration test scaffolding.

mogen_integration_tests #

mogen_integration_tests scans your Flutter app's datasource classes and generates Dio-based integration test scaffolding for discovered GET endpoints.

The package is built for projects with datasource files organized under:

  • lib/features/<feature>/data/datasources/*_remote_datasource.dart

Each discovered endpoint results in a generated test file under test/integration/features/.


What it generates #

For each GET call found inside a datasource class, the generator creates:

  • a package:test integration test file
  • a test/integration/dio_helper.dart helper import
  • a setUp() block that builds a fresh Dio client
  • a dio.get(...) request to the discovered endpoint
  • a 2xx status code assertion

Expected project layout #

The CLI expects datasource files at the following path pattern:

lib/
└── features/
    └── auth/
        └── data/
            └── datasources/
                └── auth_remote_datasource.dart

Data source file names must end with _remote_datasource.dart.


Installation #

Add this package to your Flutter app's dev_dependencies:

dev_dependencies:
    mogen_integration_tests:

Then install dependencies:

dart pub get

Usage #

From the root of your Flutter app, run:

dart run mogen_integration_tests

CLI options #

Flag Short Default Description
--root -r . Project root directory
--dry-run -d false Preview generated files without writing them
--verbose -v false Print progress details while scanning and generating
--help -h Show the CLI help text

Examples #

# Generate tests from the current project
dart run mogen_integration_tests

# Preview output without writing files
dart run mogen_integration_tests --dry-run --verbose

# Scan a different package root
dart run mogen_integration_tests --root /path/to/my_flutter_app

Example datasource #

import 'package:dio/dio.dart';

class AuthRemoteDataSource {
  final Dio dio;

  AuthRemoteDataSource(this.dio);

  Future<void> login() async {
    await dio.get('/Authenticate/Auth');
  }
}

Generated test output #

// GENERATED BY mogen_integration_tests — DO NOT EDIT
// ignore_for_file: lines_longer_than_80_chars

import 'package:test/test.dart';
import 'package:dio/dio.dart';

import 'package:your_app/test/integration/dio_helper.dart';

void main() {
  group('GET /Auth/Auth', () {
    late Dio dio;

    setUp(() {
      dio = buildTestDio();
    });

    test('returns a successful response', () async {
      final response = await dio.get('/Auth/Auth');

      expect(response.statusCode, inInclusiveRange(200, 299));
    });
  });
}

Notes #

  • The generator only scans GET calls in datasource methods.
  • It does not generate request-body, query-parameter, or POST/PUT request scaffolding yet.
  • test/integration/dio_helper.dart is generated as a helper placeholder; update it to match your app's environment if needed.

Supported source naming #

  • *_remote_datasource.dart files under lib/features/**/data/datasources/
  • Example: auth_remote_datasource.dart, profile_remote_datasource.dart

Dependencies #

Package Purpose
analyzer Parse Dart AST for datasource analysis
dart_style Format generated Dart output
args CLI flag parsing
dio Detect GET requests in datasource code
yaml Read pubspec.yaml for package info

Project notes #

  • This repository is a CLI package, not a Flutter app.
  • Generated files are written to test/integration/features/.
  • If you use the generator from this repository, point --root at a consumer project.
1
likes
0
points
261
downloads

Publisher

unverified uploader

Weekly Downloads

Scans datasource GET endpoints and auto-generates integration test scaffolding.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, args, dart_style, dio, glob, path, yaml

More

Packages that depend on mogen_integration_tests