testMultipleUI function

Future<void> testMultipleUI(
  1. Map<String, FutureOr<void> Function()> testsMain, {
  2. bool shuffle = false,
  3. int? shuffleSeed,
})

Executes multiple testUI in the same process/script.

  • testsMain should be a Map containing the test path and main entrypoint for each test.

Example:

import 'package:bones_ui/bones_ui_test.dart';

import 'register_testui.dart' as register_testui;
import 'search_testui.dart' as search_testui;
import 'orders_testui.dart' as orders_testui;

Future<void> main() async {
  await testMultipleUI({
    'register_testui.dart': register_testui.main,
    'search_testui.dart': search_testui.main,
    'orders_testui.dart': orders_testui.main,
  });
}

Implementation

Future<void> testMultipleUI(Map<String, FutureOr<void> Function()> testsMain,
    {bool shuffle = false, int? shuffleSeed}) async {
  var entries = testsMain.entries.toList();

  if (shuffle) {
    shuffleSeed ??= Random().nextInt(999999999);

    var random = Random(shuffleSeed);
    entries.shuffle(random);

    print('testMultipleUI> shuflle(shuffleSeed: $shuffleSeed)');
  }

  print('testMultipleUI:');
  for (var e in testsMain.entries) {
    var testPath = e.key;
    print('  -- $testPath');
  }

  print('');

  for (var e in entries) {
    var testPath = e.key;
    var main = e.value;
    _testMultipleUIPath = testPath;
    await main();
    await Future.delayed(Duration(milliseconds: 100));
  }
}