Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect(future, matcher) has an unhelpful stacktrace #2164

Open
rrousselGit opened this issue Dec 28, 2023 · 0 comments
Open

expect(future, matcher) has an unhelpful stacktrace #2164

rrousselGit opened this issue Dec 28, 2023 · 0 comments

Comments

@rrousselGit
Copy link
Contributor

rrousselGit commented Dec 28, 2023

Consider:

test('some expectations', () {
  expect(
    Future.error(42),
    throwsA(42),
  );

  expect(
    Future.error(21),
    throwsA(42),
  );
});

When this test fails, the console will render:

-1: some expectations
  Expected: throws <42>
    Actual: <Instance of 'Future<dynamic>'>
     Which: threw <21>
            stack
  
  package:test_api  OutstandingWork.complete

The problem is, this doesn't tell us which specific expectation in our test is at fault.
In the given example, there are two expectations, both of which have the exact same stacktrace if they were to fail.

I am aware that await expectLater would fix this. But mistakes happen and we may use expect instead of expectLater when it'd help.
And the "await" may change the test's behavior, so those aren't strictly equivalent either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant