Customizing Tests

Standard test parameters

The modddels test methods (isValid, isSanitized ...) can receive the same parameters as the test function (Except description and body).

These parameters are : testOn - timeout - skip - tags - onPlatform - retry

For example :

testAge.isValid(
  const AgeParams(19),
  skip: true,
  retry: 3,
);

For more information, check out the documentation of the test function.

Test Description

Each test's description is automatically generated. It uses the Gherkin syntax (given-when-then).

For isValid tests :

Given a {modddelName} {modddelKind}
When instantiated with {params}
Then the {modddelName} is a {validName}

For isSanitized tests :

For isInvalid tests :

Example : For this test :

The generated description is :

The maxTestInfoLength

As you can see, the description can contain {params}, {sanitizedParams} and {failure}. These can be quite long strings, which would cause the description to become too long and unreadable.

To keep the description short enough, each one of those strings' length is limited to maxTestInfoLength, beyond which they are ellipsized. This maxTestInfoLength defaults to 200 characters, but it can be modified by :

  1. Providing it in the modddel annotation :

  2. Providing it in the Tester's constructor. This takes priority over maxTestInfoLength set in @Modddel.

  3. Providing it in the test method itself. This takes priority over maxTestInfoLength set in the Tester's constructor.

This "ellipsisation" can be disabled by setting maxTestInfoLength to Modddel.noMaxLength (which equals -1).

Last updated