-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Proposal
Create the following conventions for matcher prefixes:
-
Partial matchers. Example:
isPerson(name: 'Loic').A partial matcher only matches the properties you provide. The matcher's arguments are
nullby default.You cannot use a partial matcher to assert a value is
null. For example, I cannot check that a person's nickname isnullusing:isPerson(name: 'Loic', nickname: null). Instead, you need to use:
expect(person, isPerson(name: 'Loic'));
expect(person.nickname, isNull);-
Exact matchers. Example:
matchesPerson(name: 'Loic', nickname: null).An exact matcher matches all the values, including those you omit. The matcher's arguments have the same default value as the object's default value.
The exact matcher is often less convenient than the partial matcher. To match an object with 20 non-default property values, you'll need to provide all 20 values to the exact matcher.
Migration
To adopt this naming convention, we'll want to:
- Codify this to our style guide
- Deprecate
containsSemanticsin favor of a newisSemanticsmatcher. (For history behindcontainsSemantics, see: AllowmatchesSemanticsto only match certain properties #107859)
cc @chunhtai