pub repository
mirror.p-hatan.irmatcher
0.12.12Support for specifying test expectations via an extensible Matcher class. Also includes a number of built-in Matcher implementations for common cases.
Readme
Dart CI pub package package publisher
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.
Best Practices
Prefer semantically meaningful matchers to comparing derived values
Matchers which have knowledge of the semantics that are tested are able to emit
more meaningful messages which don't require reading test source to understand
why the test failed. For instance compare the failures between
expect(someList.length, 1), and expect(someList, hasLength(1)):
// expect(someList.length, 1);
Expected: <1>
Actual: <2>
// expect(someList, hasLength(1));
Expected: an object with length of <1>
Actual: ['expected value', 'unexpected value']
Which: has length of <2>
Changelog
0.12.12
- Add a best practices section to readme.
- Populate the pubspec
repositoryfield.
0.12.11
- Change many argument types from
dynamictoObject?. - Fix
stringContainsInOrderto account for repetitions and empty strings.- Note: This may break some existing tests, as the behavior does change.
0.12.10
- Stable release for null safety.
0.12.10-nullsafety.3
- Update SDK constraints to
>=2.12.0-0 <3.0.0based on beta release guidelines.
0.12.10-nullsafety.2
- Allow prerelease versions of the 2.12 sdk.
0.12.10-nullsafety.1
- Allow 2.10 stable and 2.11.0 dev SDK versions.
0.12.10-nullsafety
- Migrate to NNBD.
- Apis have been updated to express intent of the existing code and how it handled nulls.
0.12.9
- Improve mismatch descriptions for deep matches. Previously, if the user tried to do a deep match where the expectation included a complex matcher (such as a "having" matcher), the failure message would just say "failed to match ..."; it wouldn't call on the expectation's matcher to explain why the match failed.
0.12.8
- Add a mismatch description to
TypeMatcher.
0.12.7
- Deprecate the
mirror_matchers.dartlibrary.
0.12.6
- Update minimum Dart SDK to
2.2.0. - Consistently point to
isAas a replacement forinstanceOf. - Pretty print with private type names.
0.12.5
- Add
isA()to createTypeMatcherinstances 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<and not=. This could cause tests which relied on this bug to start failing.
0.12.4
- Add isCastError.
0.12.3+1
- Set max SDK version to <3.0.0, and adjusted other dependencies.
0.12.3
-
Many improvements to
TypeMatcher-
Can now be used directly as
const TypeMatcher<MyType>(). -
Added a type parameter to specify the target
Type.- Made the
nameconstructor parameter optional and marked it deprecated. It's redundant to the type parameter.
- Made the
-
Migrated all
isTypematchers toTypeMatcher. -
Added a
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);
-
-
Deprecated the
isInstanceOfclass. UseTypeMatcherinstead. -
Improved the output of
Matcherinstances that fail due to type errors.
0.12.2+1
- Updated SDK version to 2.0.0-dev.17.0
0.12.2
-
Fixed
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.
0.12.1+4
- Fixed SDK constraint to allow edge builds.
0.12.1+3
-
Make
predicateandpairwiseComparegeneric 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.
0.12.1+2
-
Fixed small documentation issues.
-
Fixed small issue in
StringEqualsMatcher. -
Update to support future Dart language changes.
0.12.1+1
- Produce a better error message when a
CustomMatcher's feature throws.
0.12.1
- Add containsAllInOrder matcher for Iterables
0.12.0+2
- Fix all strong-mode warnings.
0.12.0+1
- Fix test files to use
testinstead ofunittestpkg.
0.12.0
-
Moved a number of members to the
unittestpackage.TestFailure,ErrorFormatter,expect,fail, and 'wrapAsync'.completes,completion,throws, andthrowsAMatchers.- The
Throwsclass. - All of the
throws...ErrorMatchers.
-
Removed
FailureHandler,DefaultFailureHandler,configureExpectFailureHandler, andgetOrCreateExpectFailureHandler. Now thatexpectis in theunittestpackage, these are no longer needed. -
Removed the
nameparameter forisInstanceOf. This was previously deprecated, and is no longer necessary since all language implementations now support converting the type parameter to a string directly.
0.11.4+6
- Fix a bug introduced in 0.11.4+5 in which operator matchers broke when taking lists of matchers.
0.11.4+5
- Fix all strong-mode warnings.
0.11.4+4
- Deprecate the name parameter to
isInstanceOf. All language implementations now support converting the type parameter to a string directly.
0.11.4+3
- Fix the examples for
equalsIgnoringWhitespace.
0.11.4+2
- Improve the formatting of strings that contain unprintable ASCII characters.
0.11.4+1
- Correctly match and print
Strings containing characters that must be represented as escape sequences.
0.11.4
- Remove the type checks in the
isEmptyandisNotEmptymatchers and simply access theisEmptyrespectivelyisNotEmptyfields. This allows them to work with custom collections. See Issue 21792 and Issue 21562
0.11.3+1
- Fix the
printsmatcher test on dart2js.
0.11.3
- Add a
printsmatcher that matches output a callback emits viaprint.
0.11.2
- Add an
isNotEmptymatcher.
0.11.1+1
-
Refactored libraries and tests.
-
Fixed spelling mistake.
0.11.1
- Added
isNaNandisNotNaNmatchers.
0.11.0
- Removed deprecated matchers.
0.10.1+1
- Get the tests passing when run on dart2js in minified mode.
0.10.1
- Compare sets order-independently when using
equals().
0.10.0+3
- Removed
@deprecatedannotation on matchers due to Issue 19173
0.10.0+2
- Added types to a number of constants.
0.10.0+1
-
Matchers related to bad language use have been removed. These represent code structure that should rarely or never be validated in tests.
isAbstractClassInstantiationErrorthrowsAbstractClassInstantiationErrorisFallThroughErrorthrowsFallThroughError
-
Added types to a number of method arguments.
-
The structure of the library and test code has been updated.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add matcherpubspec.yaml
name: matcher
version: 0.12.12
description: >-
Support for specifying test expectations via an extensible Matcher class.
Also includes a number of built-in Matcher implementations for common cases.
repository: https://github.com/dart-lang/matcher
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
stack_trace: ^1.10.0
dev_dependencies:
lints: ^1.0.0
test: any
test_api: any
test_core: any
dependency_overrides:
test_api: any
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.10.0 | 2014-03-22T00:54:13.013700Z | Download | f871040ef3dba89996b15cad850f537d80c2e885a9f49650627472e9341af2cb |
| 0.10.0+1 | 2014-06-02T17:57:36.612700Z | Download | 4fe45eacf62b1477238313265be4fcd4edab212e4b71a767d37c4fe75c178733 |
| 0.10.0+2 | 2014-06-02T20:28:02.850360Z | Download | fcfcc752c86c02a2799cf55adcca24c626ee4092df7b3108b4718fc7f6c82688 |
| 0.10.0+3 | 2014-06-05T19:37:01.812620Z | Download | 88cd3c7e81546be2d7772101c8d6a2c66ce09cc8115c2db593ee5e78f0837f4f |
| 0.10.1 | 2014-06-12T20:15:47.518480Z | Download | d1b2fbbf91de462a213b84bfa80dee634258ba9ce645a914ef46877df1a3536e |
| 0.10.1+1 | 2014-06-12T21:18:59.173890Z | Download | 1bc2bd985eb2ff2289795d4585e60105223aa010562b12d97aacfb1211174410 |
| 0.11.0 | 2014-07-22T22:55:51.596260Z | Download | c51d68147c3626ff48d5aef503c67d23891b15356493c9e0b159b8665e6b8315 |
| 0.11.1 | 2014-07-31T01:15:51.078600Z | Download | 8b02756d9c9dbf0431ec3e5cb6a7aa7d9b36b2c8817886507789c3cc3544d54f |
| 0.11.2 | 2014-12-04T21:28:35.955370Z | Download | dfd1de433550332f966a12e94bf03a749d9e0575b5116dcb0ed507286a1eec43 |
| 0.11.3 | 2014-12-10T22:52:29.315610Z | Download | 6f4bfc394454cdf67ae0322097b4b8a12ce4664a5becc681f5e63ddd9c075945 |
| 0.11.4 | 2015-01-13T00:03:48.851090Z | Download | 040d7f1e6de13ed4226bef57d75cf6ef34dcdd5b36bfa29e9d10ee807050f399 |
| 0.11.4+1 | 2015-02-10T22:33:00.146210Z | Download | 0958fa803b8188baa17f219cd3d990fc9e5ab4660d4ed3bff961dedd087c8538 |
| 0.11.4+2 | 2015-03-05T01:37:47.318930Z | Download | 703b5cff2571912fd0a5a51439b157e221653813d82a4648a149b40c6430ba8a |
| 0.11.4+3 | 2015-03-09T21:42:01.667120Z | Download | 0cf7fa23af8423cda02bca91d915a225710929c55b74548dd95a8e34fc2098f9 |
| 0.11.4+4 | 2015-03-24T21:56:05.354460Z | Download | 8a361603a38e6dda4d5d547f20d0a903b943b49f00fc73283a4d728753931084 |
| 0.11.4+5 | 2016-03-24T19:17:01.926Z | Download | d821fddcfa2936553741121eabb10fc66ec6a8a28e9a12012679f9111274acd8 |
| 0.11.4+6 | 2016-03-24T20:39:43.387Z | Download | 39e315c924b69aeedd05712b346c04d28e4cd0857e420659fd83119acbc015d0 |
| 0.12.0-alpha.0 | 2015-02-20T00:43:04.111Z | Download | 8e8521d89633bdd61a18ebb085a63f6649c17ead68cef4d8a9a1d4d0f281d89b |
| 0.12.0 | 2015-04-30T00:54:52.208Z | Download | 10c5acc8332b71f62028612b3b060833c9b8c23e7fcfa1384020eae48d55f704 |
| 0.12.0+1 | 2015-05-21T17:31:28.933Z | Download | 4cb59fd0605a52bc7ced01aba0fc78aa97560ff3a86da23d5c53345e55a0f96f |
| 0.12.0+2 | 2016-03-24T20:41:13.416Z | Download | 66fe71ebcbd7064b6a492973775f1ba91bbf0b8bf1e8d86d545062d8ff35c2d9 |
| 0.12.1 | 2017-05-05T19:06:14.292475Z | Download | 0af3e6198aa6824814f04fbc7f30d55d6e477f55e5a4869e4c2bcf66544a6d08 |
| 0.12.1+1 | 2017-05-27T00:34:25.852739Z | Download | 6f9059b39f3191a4fe9650e91e548a4381a8426709bd4b65986a064085d9ed58 |
| 0.12.1+2 | 2017-08-30T23:01:50.704654Z | Download | 3639fa52b0b70e9b55073cb3b5009fa9a53341707fa39c4b11031b7e9adb7bce |
| 0.12.1+3 | 2017-09-05T21:41:44.661933Z | Download | bee81a33aec304b570eff21f49137d95ab2f297bae64a6f7ac3fbb2d0bd946d8 |
| 0.12.1+4 | 2017-09-20T20:09:04.431746Z | Download | c6a33eecdb65244d5304b2d26e183c164d81eddf1631c64758bc0aee386d0e11 |
| 0.12.2 | 2018-04-12T22:18:05.119656Z | Download | 59e807ce4305ef1441a06d2ab6d2755621be1fd5651aa38772aa715a4f43ac8d |
| 0.12.2+1 | 2018-05-03T22:09:29.113032Z | Download | 5ea7e7209ade699d9956be21339351d5cb89d4bbdce51ff41a969d332653b792 |
| 0.12.3 | 2018-06-14T22:43:01.907675Z | Download | 93124cd404f8de7c7e4d5eb4e56a178b0a82b521b3ef9325496ee29b4cebe638 |
| 0.12.3+1 | 2018-07-16T19:27:08.192121Z | Download | ef2adb68b8e420bd089f48a551798e4f32e7acfac82a445da972410090503526 |
| 0.12.4 | 2018-07-17T20:26:05.530959Z | Download | c78a72c2f7f9c31eb35bf4a967b80d30c87b406df65a8511da5e4a36064a18b5 |
| 0.12.5 | 2019-03-22T20:27:13.888038Z | Download | 0fea0971b41ea65a79e01b8193167e4dae5b58fb8374dcd070946a5ea40d5200 |
| 0.12.6 | 2019-10-21T20:02:36.669978Z | Download | fc649fa7647ac826aec7ac2be1387c155f26fe55e03c16df020a4fe0e7419f21 |
| 0.12.8 | 2020-06-16T20:22:06.869530Z | Download | dc850a141ec6bfdb17d5c7f873ff7b473ef0a023ea39e4bf1556410698189675 |
| 0.12.9 | 2020-07-13T20:57:44.850742Z | Download | 34a9b8fdeda855a39a259e16604be0298fc9ff23ae8cb352016960b7e3f0e767 |
| 0.12.10-nullsafety | 2020-07-29T15:53:07.046288Z | Download | cb7611da57f9217637030d6103bbf49bd4eb559f5f1d7060b603ffbcfe702a62 |
| 0.12.10-nullsafety.1 | 2020-09-22T15:52:08.352456Z | Download | ab0169fb621f8139e68b2801005a9601076ca5055f789541fdc24ceb97e2b987 |
| 0.12.10-nullsafety.2 | 2020-10-23T19:58:35.531279Z | Download | 8fa1bbe9dcf2f3c7eb0ae3dbc6a41e7b2aec27e216783b4b74d843233fcd7af2 |
| 0.12.10-nullsafety.3 | 2020-11-03T20:44:10.748917Z | Download | e7e41604a1648d87765e9928e7251dccca17198f786745c9e31cad5c090641b5 |
| 0.12.10 | 2021-02-02T23:43:47.968651Z | Download | 38c7be344ac5057e10161a5ecb00c9d9d67ed2f150001278601dd27d9fe64206 |
| 0.12.11 | 2021-08-12T17:54:24.176756Z | Download | 2e2c34e631f93410daa3ee3410250eadc77ac6befc02a040eda8a123f34e6f5a |
| 0.12.12 | 2022-06-15T20:54:43.458056Z | Download | 80c2989398773fa06e2457e9ff08580f24e9858b28462a722241cb53e5613478 |
| 0.12.13 | 2022-10-25T16:23:31.993574Z | Download | 16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72 |
| 0.12.14 | 2022-12-13T19:00:51.899426Z | Download | c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8 |
| 0.12.15 | 2023-03-22T01:12:08.256400Z | Download | 6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb |
| 0.12.16 | 2023-05-02T04:24:54.094638Z | Download | 1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e |
| 0.12.16+1 | 2023-12-13T19:38:54.836554Z | Download | d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb |
| 0.12.17 | 2024-10-18T08:47:56.147427Z | Download | dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 |
| 0.12.18 | 2025-11-20T23:35:48.383270Z | Download | 12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6 |
| 0.12.19 | 2026-02-27T01:52:58.341450Z | Download | dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 |
| 0.12.20 | 2026-04-27T20:39:05.888392Z | Download | 31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd |
Dependencies
stack_trace "^1.10.0"