testWithRandom method

  1. @isTest
void testWithRandom(
  1. String description,
  2. TesterWithRandom<T> body, {
  3. String? testOn,
  4. Timeout? timeout,
  5. dynamic skip,
  6. dynamic tags,
  7. Map<String, dynamic>? onPlatform,
  8. int? retry,
})

Implementation

@isTest
void testWithRandom(
  String description,
  TesterWithRandom<T> body, {
  String? testOn,
  test_package.Timeout? timeout,
  dynamic skip,
  dynamic tags,
  Map<String, dynamic>? onPlatform,
  int? retry,
}) {
  // How many random values the test needs shouldn't change what other inputs
  // are chosen. Otherwise, if a test fails, you edit the content and then the
  // test succeeds, you're not sure what made the test succeed:
  //
  // - Maybe you fixed the root problem.
  // - Or you changed some calls to the random instance, causing the faulty
  //   input to never be generated in the first place.
  final random = explore.random.nextRandom();
  test(
    description,
    (a) => body(a, random.nextRandom()),
    testOn: testOn,
    timeout: timeout,
    skip: skip,
    tags: tags,
    onPlatform: onPlatform,
    retry: retry,
  );
}