Support for specifying test expectations, such as for unit tests.
The matcher library provides a third-generation assertion mechanism, drawing inspiration from Hamcrest.
For more information, see Unit Testing with Dart.
- Update minimum Dart SDK to
- Consistently point to
isAas a replacement for
- Pretty print with private type names.
TypeMatcherinstances in a more fluent way.
- Potentially breaking bug fix. Ordering matchers no longer treat objects
with a partial ordering (such as NaN for double values) as if they had a
complete ordering. For instance
greaterThannow compares with the
>operator rather not
=. This could cause tests which relied on this bug to start failing.
- Add isCastError.
- Set max SDK version to <3.0.0, and adjusted other dependencies.
Many improvements to
Can now be used directly as
Added a type parameter to specify the target
- Made the
nameconstructor parameter optional and marked it deprecated. It's redundant to the type parameter.
- Made the
havingfunction that allows chained validations of specific features of the target type.
/// Validates that the object is a [RangeError] with a message containing /// the string 'details' and `start` and `end` properties that are `null`. final _rangeMatcher = isRangeError .having((e) => e.message, 'message', contains('details')) .having((e) => e.start, 'start', isNull) .having((e) => e.end, 'end', isNull);
Improved the output of
Matcherinstances that fail due to type errors.
- Updated SDK version to 2.0.0-dev.17.0
unorderedMatchesin cases where the matchers may match more than one element and order of the elements doesn't line up with the order of the matchers.
Add containsAll matcher for Iterables. This Matcher checks that all values/matchers in an expected iterable are satisfied by an element in the value without allowing the same value to satisfy multiple matchers.
- Fixed SDK constraint to allow edge builds.
pairwiseComparegeneric methods to allow typed functions to be passed to them as arguments.
Make internal implementations take better advantage of type promotion to avoid dynamic call overhead.
Fixed small documentation issues.
Fixed small issue in
Update to support future Dart language changes.
- Produce a better error message when a
CustomMatcher's feature throws.
- Add containsAllInOrder matcher for Iterables
- Fix all strong-mode warnings.
- Fix test files to use
Moved a number of members to the
fail, and 'wrapAsync'.
- All of the
getOrCreateExpectFailureHandler. Now that
expectis in the
unittestpackage, these are no longer needed.
isInstanceOf. This was previously deprecated, and is no longer necessary since all language implementations now support converting the type parameter to a string directly.
- Fix a bug introduced in 0.11.4+5 in which operator matchers broke when taking lists of matchers.
- Fix all strong-mode warnings.
- Deprecate the name parameter to
isInstanceOf. All language implementations now support converting the type parameter to a string directly.
- Fix the examples for
- Improve the formatting of strings that contain unprintable ASCII characters.
- Correctly match and print
Strings containing characters that must be represented as escape sequences.
- Remove the type checks in the
isNotEmptymatchers and simply access the
isNotEmptyfields. This allows them to work with custom collections. See Issue 21792 and Issue 21562
- Fix the
printsmatcher test on dart2js.
- Add a
printsmatcher that matches output a callback emits via
- Add an
Refactored libraries and tests.
Fixed spelling mistake.
- Removed deprecated matchers.
- Get the tests passing when run on dart2js in minified mode.
- Compare sets order-independently when using
@deprecatedannotation on matchers due to Issue 19173
- Added types to a number of constants.
Matchers related to bad language use have been removed. These represent code structure that should rarely or never be validated in tests.
Added types to a number of method arguments.
The structure of the library and test code has been updated.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: matcher: ^0.12.6
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.1
- pana: 0.13.5
lib/src/string_matchers.dart. (-0.50 points)
lib/src/string_matchers.dart reported 1 hint:
line 50 col 16: The value of the field '_value' isn't used.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
matcher.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.