commit | ab665ce6cb7a5caa91b925ad3699b50fe356cebf | [log] [tgz] |
---|---|---|
author | Paul Berry <stereotype441@gmail.com> | Thu Jul 09 13:03:24 2020 -0700 |
committer | GitHub <noreply@github.com> | Thu Jul 09 13:03:24 2020 -0700 |
tree | 771f07af07caed2cb9f574f303f27cf999704576 | |
parent | 08e8d847782fea147b60309e3a6d45cdf890e7f1 [diff] |
Rework _DeepMatcher so that it can display details of match failures. (#143) 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. `_DeepMatcher` now stores a `_Mismatch` object in the matchState map (under the key `mismatch`) recording in detail the location of the mismatch, the actual and expected values, and if necessary, a callback that describes the problem in more detail. This replaces the old `reason` object, which was a String. Using a `_Mismatch` object allows us to pass the `verbose` flag through when calling on the inner expectation's matcher to explain why the match failed. It also avoids unnecessary string operations if no description is needed.
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.