property function

  1. @isTest
void property(
  1. Object? description,
  2. FutureOr<void> body(), {
  3. String? testOn,
  4. Timeout? timeout,
  5. Object? skip,
  6. Object? tags,
  7. Map<String, dynamic>? onPlatform,
})

Executes a property-based test, acting as a wrapper around the test function from the test package.

To perform property testing, use forAll within the body of check to specify properties that your code must satisfy. forAll generates inputs based on provided constraints and repeatedly executes the test body with those inputs to verify the specified properties across a wide range of cases.

Parameters:

  • description: A description of the test, which can help identify the test when it's run or when it fails.
  • body: The test body as a function, where property tests are defined using forAll.
  • testOn: Specifies which platforms the test should run on.
  • timeout: Sets a timeout for the test. If the test runs longer, it will be marked as failed.
  • skip: Allows skipping the test. Can be a boolean or a string explaining why the test is skipped.
  • tags: Used to tag the test with one or more labels, facilitating selective test runs.
  • onPlatform: Specifies overrides for timeout or skip on a per-platform basis.

Implementation

@isTest
void property(
  Object? description,
  FutureOr<void> Function() body, {
  String? testOn,
  Timeout? timeout,
  Object? skip,
  Object? tags,
  Map<String, dynamic>? onPlatform,
}) {
  final test = PropertyTest(
    description,
    body,
    testOn: testOn,
    timeout: timeout,
    skip: skip,
    tags: tags,
    onPlatform: onPlatform,
  );
  PropertyTestManager.addTest(test);
}