Skip to content

Allow multiple patterns for nested checks to allow higher consistency between synchronous and asynchronous checks #2695

Description

@natebosch

There are currently 2 styles of writing tests which check "nested" conditions - conditions that are checked against a value derived from the original subject. Synchronous checks nest with method chaining like check(foo).isNotNull().isGreaterThan(1), while asynchronous checks nest with Condition callbacks await check(foo).completes((it) => it.isGreaterThan(1));. The reason for the divergence is the awkward syntax needed to handle the await for nesting await (await check(foo).completes()).isGreaterThan(1);

Some authors may have a preference to match the styles. We could normalize these and allow either style - synchronous nested checks with Condition arguments and asynchronous nested checks that return Future<Subject>. The reason not to do this is it violates the preference for having one way of accomplishing goals and forcing a choice onto every author. If we don't do this there will be authors who are disappointed not to be able to use their preferred style.

I have a PR which does this #2683 - but I haven't asked folks to decide their preference because I was pushing on a PR for #2694 too which is worth considering together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    package:checksIssues related to pkg:checks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions